Logging - have logger use caller's function name and line number
Malcolm Greene
python at bdurham.com
Sat Dec 29 13:48:00 EST 2018
I have a class method that adds additional context to many of the
class's log messages. Rather than calling, for example, logger.info(
'message ...' ) I would like to call my_object.log( 'message ...' ) so
that this additional context is managed in a single place. I'm actually
doing that and its working great except that ... as expected ... all my
log records have the my_object.log method's name and line numbers vs the
callers' names and line numbers.
Is there a technique I can use to have my custom log method inject the
caller's name and line numbers in the log output?
More information about the Python-list
mailing list