Question by someone coming from C...

John Krukoff jkrukoff at ltgc.com
Mon Jun 9 18:17:26 EDT 2008


On Mon, 2008-06-09 at 15:02 -0700, Skye wrote:
> On Jun 9, 2:35 pm, Matimus <mccre... at gmail.com> wrote:
> > The only time to do that sort of thing (in python) is when interacting
> > with something else that isn't written in Python though. In general,
> > for logging, just use the standard logging module:http://docs.python.org/lib/module-logging.html
> 
> Thanks!  It looks like subclassing the logging module would be a much
> better idea :)
> 
> Skye
> 
> --
> http://mail.python.org/mailman/listinfo/python-list

Really, the logging module is heavy weight enough, it's very doubtful
you need to add any functionality at all.

If you look at the documentation for logger objects, you'll see that you
can use a number of them, and set different logging levels for each one.
So, to get equivalent functionality to your bitfields, instead make a
separate logger for each category (config, options, blah...) and call
the object to log for that type.

i.e. config.debug( ... ), options.error( ... )

Since you probably want access to these from many different places in
your code, I find the simplest way is to create a logging module of your
own (not called logging, obviously) and instantiate all of your loggers
in that namespace, then import that one module as needed.

Perhpas you want one logging message to qualify as several different
types? That's the only place where I could see this being too verbose,
but even then it'd be easy to make a wrapper function that made that
easy given a collection of loggers.
-- 
John Krukoff <jkrukoff at ltgc.com>
Land Title Guarantee Company




More information about the Python-list mailing list