Roy Smith wrote:
MRAB <pyt...@mrabarnett.plus.com> wrote:

or use 'globals':

     def function(self):
         logger = globals()['logger'].getChild('function')
         logger.debug('stuff')
         logger.debug('other stuff')

Ah-ha!  That's precisely what I was looking for.  Much appreciated.
Using the same name for 2 different objects is a bad idea in general.
In debug mode, i.e. the logger is configured with the debug level, you could simply write down the filename and the line number on your log events.

formatter = logging.Formatter('%(name)s : %(filename)s %(lineno)s %(message)s')

So you can easily see who logged what (if I'm not wrong, that's what you're trying to do)

JM
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to