create a log level for python logging module
vinay_sajip at yahoo.co.uk
Mon Mar 30 23:18:47 CEST 2009
On Mar 30, 4:13 pm, dj <d.a.aberna... at gmail.com> wrote:
> I am trying to create a log level called userinfo for the pythonlogging. I read the source code and tried to register the level to theloggingnamespace with the following source:
> fromloggingimport Logger
> # create the custom log level
> class userinfo(Logger):
> def userinfo(self, msg,
> *args, **kwargs):
> self._log(WARNING, msg, args, **kwargs)
> # Register log level in thelogging.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.
See the example script at
which contains, amongst other things, an illustration of how to use
custom logging levels in an application.
More information about the Python-list