Hi,

I've create a Python file called "log.py" and placed in the custom levels:

# Performance Debug...
logging.addLevelName(PDEBUG_NUM, "PDEBUG")

def pdebug(self, message, *args, **kws):
    """ Performance Debug Message Level """
    self.log(PDEBUG_NUM, message, *args, **kws) 
        
logging.Logger.pdebug = pdebug


This works except that the %(module) and %(lineno) does not print properly, it 
instead prints out as the "log.py" and the line that this is on. I think I 
figured out a way to get the module and line from the calling custom level:

import inspect
frame = inspect.currentframe()
filename = 
os.path.splitext(os.path.basename(frame.f_back.f_code.co_filename))[0]
linenumber = frame.f_back.f_lineno


My question is how do I pass this into the "self.log" call properly? I've tried 
a few different things without any luck. Any ideas how I can pass this into the 
custom logging level and get it to work?

Thanks in Advance for any help!
    Tom
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to