473,466 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1094

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: rh0dium | last post by:
Hi all, So I have a slice of code which calls other python code. I have started to take a real liking to the logging module, but I want to extend this into the called python code. I have no...
23
by: Rotem | last post by:
Hi, while working on something in my current project I have made several improvements to the logging package in Python, two of them are worth mentioning: 1. addition of a logging record field...
3
by: Lowell Alleman | last post by:
Here is the situation: I wrote my own log handler class (derived from logging.Handler) and I want to be able to use it from a logging config file, that is, a config file loaded with the...
1
by: Matimus | last post by:
Yes but in the other hand :http://docs.python.org/library/logging.html#logger-objects That is part of the power of the logging module. If you ask for a logger of the same name in two different...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.