471,330 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

Extending logging module

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
0 1001

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

23 posts views Thread by Rotem | last post: by
3 posts views Thread by Lowell Alleman | last post: by
1 post views Thread by Matimus | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.