On Sun, 30 Dec 2018 at 05:58, Malcolm Greene <pyt...@bdurham.com> wrote: > > 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?
You can use this: https://docs.python.org/3/library/inspect.html#the-interpreter-stack -- https://mail.python.org/mailman/listinfo/python-list