By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,345 Members | 1,746 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,345 IT Pros & Developers. It's quick & easy.

Extending logging module

P: n/a
jay
Hello,

I've been using the python logging module a lot lately, and I've come
across an instance where I need some new levels. Specifically, python
does not include ALERT and NOTICE in the default set of logging
levels. I am wondering how trivial it would be to extend the logging
module to include these 2 levels that are standard with syslog?

My first test was just to use the addLevelName method to add the two
new levels, but syslog ignores them and logs at the next highest
priority, no matter what I use.

Looking further into the code and as a test, I changed the following
to see if this would even work

lib/python2.5/logging/__init__.py
-class Logger
-add new notice and alert root level functions
-new _levelNames for notice and alert
-new default level names for notice and alert

lib/python2.5/logging/handlers.py
-class SysLogHandler priority_map was changed to include notice
and alert

It actually worked, but this is not the way I would like to handle the
problem. I would prefer to extend the classes instead. However, I'm
not too familiar with that, and I had to change things in so many
places, I'm wondering if its even possible? I don't like changing the
standard libraries, what happens if I have to upgrade python? My
changes get overwritten.

Can anyone offer some help or suggestions? Thanks

Jay

Aug 9 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.