Antoine Pitrou <pit...@free.fr> added the comment:

Perhaps a recipe should be published to explain how to add your own levels?

e.g.:

>>> import logging
>>> logging.NOTE = logging.INFO + 5
>>> logging.addLevelName(logging.INFO + 5, 'NOTE')
>>> class MyLogger(logging.Logger):
...:    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")
Level 25:foo:hello Guido

----------
nosy: +pitrou

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31732>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to