# assuming loglevel is bound to the string value obtained from the # command line argument. Convert to upper case to allow the user to # specify --log=DEBUG or --log=debug numeric_level = getattr(logging, loglevel.upper(), None) if not isinstance(numeric_level, int): raise ValueError('Invalid log level: %s' % loglevel) logging.basicConfig(level=numeric_level, ...)
Is there a practical reason why the above doesn't work for you? Otherwise, I see no reason to add a new environment variable that effectively does the same thing.
Another idea I've had that may be of use:_______________________________________________PYTHONLOGGING environment variable.Setting PYTHONLOGGING to any log level or level name will initialize logging.basicConfig() with that appropriate level.Another option would be that -x dev or a different -x logging will initialize basic config.Will be useful mostly for debugging purposes instead of temporarily modifying the code.Kinda surprised it doesn't exist tbh.Bar Harel
Python-ideas mailing list -- email@example.com
To unsubscribe send an email to firstname.lastname@example.org
Message archived at https://email@example.com/message/I74LVJWJLE2LUCCZGOF5A5JDSDHJ6WX2/
Code of Conduct: http://python.org/psf/codeofconduct/