Recommended format for --log-level option
Peter Otten
__peter__ at web.de
Tue Sep 25 03:45:11 EDT 2018
Victor Porton wrote:
> What is the recommended format for --log-level (or --loglevel?) command
> line option?
>
> Is it a number or NOTSET|DEBUG|INFO|WARNING|ERROR|CRITICAL?
Not really a recommendation, but I use
choices=["DEBUG", ..., "CRITICAL"],
type=str.upper
It's not clear to me what it means to set the logging level to NOTSET, so I
left that one out. The type allows me to invoke the script
./script.py --log-level warning
which I find more convenient to...
type.
When I don't need that level of detail I use
level = logging.DEBUG if args.verbose else logging.ERROR
or similar.
> Or should I accept both numbers and these string constants?
Well, I don't even remember those numbers ;)
More information about the Python-list
mailing list