create a log level for python logging module

D

dj

I am trying to create a log level called userinfo for the python
logging. I read the source code and tried to register the level to the
logging namespace with the following source:

from logging import Logger

# create the custom log level
class userinfo(Logger):
def userinfo(self, msg,
*args, **kwargs):
if
self.isEnabledFor(WARNING):

self._log(WARNING, msg, args, **kwargs)

# Register log level in the
logging.Logger namespace
Logger.userinfo = userinfo


Has I am sure you guessed, it did not work. If you know how this is
done or know what I am doing work or can provide a link to example
code (because I have not been able to locate any), I would greatly
appreciate it.
My sincere and heartfelt thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top