Re: customizing a logging logger

2007-09-13 Thread Vinay Sajip
On 12 Sep, 19:17, [EMAIL PROTECTED] wrote: > It seems like using something other than a literal string in the > message is the way to go, since I assume that its __repr__() won't get > called unless the logger is actually going to log a message for it. > Is that right? > > Are any of the other meth

Re: customizing a logging logger

2007-09-12 Thread garyjefferson123
On Sep 12, 10:46 am, Vinay Sajip <[EMAIL PROTECTED]> wrote: > 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 v

Re: customizing a logging logger

2007-09-12 Thread Vinay Sajip
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

Re: customizing a logging logger

2007-09-11 Thread David
On 9/11/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I think the following question is clearer. > > I want to make it so that method1 below can be transformed: > > logger = logging.getLogger("somelogger") > class SomeOp: > def __init__(self, ctx): > self.ctx = ctx > def method

Re: customizing a logging logger

2007-09-11 Thread garyjefferson123
I think the following question is clearer. I want to make it so that method1 below can be transformed: logger = logging.getLogger("somelogger") class SomeOp: def __init__(self, ctx): self.ctx = ctx def method1(self): logger.info("%s: here's a message", self.ctx) lo

customizing a logging logger

2007-08-17 Thread garyjefferson123
Suppose I have some sort of context variable that I want to appear in log messages. E.g.: logger = logging.getLogger("somelogger") class SomeOp: def __init__(self, ctx): self.ctx = ctx def method1(self): logger.info("%s: here's a message", self.ctx) What's the idiomatic w