Prepend to logging message

Joan Miller peloko45 at
Sun Jan 10 02:01:54 CET 2010

How to prepend anything to a logging message? Is possible to do it
from the dictionary object (ExtraLog) or is there is that override
process() [1]?

class ExtraLog(object):

    def __getitem__(self, name):
        if name == 'foo':
            result = 'testing'
        return result

    def __iter__(self):
        keys = ['foo',]
        return iter(keys)

logger = logging.LoggerAdapter(logging.getLogger('foo'), ExtraLog())


More information about the Python-list mailing list