[issue31732] Add TRACE level to the logging module
Antoine Pitrou
report at bugs.python.org
Tue Nov 28 15:41:25 EST 2017
Antoine Pitrou <pitrou at free.fr> added the comment:
Perhaps a recipe should be published to explain how to add your own levels?
>>> import logging
>>> logging.NOTE = logging.INFO + 5
>>> logging.addLevelName(logging.INFO + 5, 'NOTE')
>>> class MyLogger(logging.getLoggerClass()):
...: def note(self, msg, *args, **kwargs):
...: self.log(logging.NOTE, msg, *args, **kwargs)
...:
>>> logging.setLoggerClass(MyLogger)
>>> logging.basicConfig(level=logging.INFO)
>>> logger.note("hello %s", "Guido")
NOTE:foo:hello Guido
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31732>
_______________________________________
More information about the Python-bugs-list
mailing list