[py-dev] Adding logdebug option to defaultconftest.py

Grig Gheorghiu grig at gheorghiu.net
Wed Jun 15 01:12:18 CEST 2005


Forgot to copy the py-dev list....

--- holger krekel <hpk at trillke.net> wrote:

> On Tue, Jun 14, 2005 at 15:56 -0700, Grig Gheorghiu wrote:
> > --- holger krekel <hpk at trillke.net> wrote:
> > > I am starting to think about using
> > > py.log here and there and it seems like i am actually going 
> > > for something like: 
> > > 
> > >     class Something: 
> > >         log = py.log.Producer('something')
> > > 
> > >         def method(self): 
> > >             ...
> > >             self.log.adhoccategory("processing", x) 
> > > 
> > > this shows by default on stdout unless you set a catch-all 
> > > consumer or a specific one for e.g. 'something'. 
> > > 
> > > the "debugging" aspect then becomes a matter of defining 
> > > which logging information i care for (which could be changed
> > > interactively or per command line switches as you suggested)
> > > Do that make sense to you? 
> > 
> > Yes, it makes sense to me. I guess I was thinking more in terms of
> > 'consumers' (which interface more heavily with the logging module),
> > whereas you're approaching it in terms of 'agnostic' producers. So
> I
> > think you're right, it doesn't make sense to burden the set_logger
> > function with yet another parameter.
> 
> right, that's at least the experimental approach.  We'll see how
> it plays out. 
> 
> > Maybe the logging level should only be a parameter to the specific
> > loggers defined in consumer.py: File, Stdout, Stderr, Email, etc.
> Right
> > now it's arbitrarily set to logging.DEBUG.
> 
> Doesn't the logging module offer the underlying output/formatting
> logic in a more raw form, maybe?  Or else, isn't the logic needed for
> File, Stdout and Stderr trivial to implement?  We then probably
> don't need to bother with the logging module at all. 

I'll look into using more low-level functions/classes from the logging
module. As far as implementing its functionality from scratch: at least
for File/Stdout/Stderr it wouldn't be very hard to do, but then we'd
need to worry about thread safety etc., which are issues that the
logging module takes care for you. Plus the whole mechanism of
registering various handlers for various severity levels is pretty
nice,  although again it wouldn't be that hard to mimic.

> Btw, I don't know how the logging's email backend works but there
> probably is some "commit()" like function that actually
> triggers sending a mail, or not? I probably don't want an email
> message on each logging entry :-)

My understanding is that it DOES send an email per log entry :-(, but I
haven't tinkered with the SMTP logging backend that much yet. I'll be
playing with it, as well as the Syslog and WinEvent stuff, and I'll let
you know what I find.

Grig


More information about the py-dev mailing list