On 11 Sep, 17:14, [EMAIL PROTECTED] wrote:
> What is the best way to do this, so that I don't have to manually put
> the self.ctx in the log string in hundreds of different places?
>

Another way is to generate your log messages via a factory method
which prepends the context: you can do this via a mixin, too.

def log_message(self, msg):
    return "%s: %s" % (self.ctx, msg)

Note also that in recent versions, an optional "extra" parameter can
be used, to pass info into the LogRecord.

See http://mail.python.org/pipermail/patches/2007-January/021535.html
which may be of some help - it's a similar use case.

Best regards,

Vinay Sajip

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

Reply via email to