Optional use of logging library module
Neil Benn
benn at cenix-bioscience.com
Thu Jun 24 10:08:55 EDT 2004
Eric DeWall wrote:
>In trying to clean up the inevitable debug printing littered through some
>code, I started reading up on the 'logging' module. Browsing groups
>indicates that the design of the module is controversial but personally I'm
>very happy to see such a full-featured logger as part of the standard
>distribution. Here's my problem though (using 2.3.3) - I'm trying to write
>some reusable classes that _optionally_ use the logging module. So a class
>might look like:
>
>
>
<snip>
Hello,
This is an idea by you could do this :
* None or some other ID is passed in (ala the void pattern) as
your Logger
* The Logger is created as a genuine logger
* The logger has propagate set to false to stop messages going upwards
* The logger has it's severity level set so that no messages are logged
OR, you could do this
* None or some other ID is passed in (ala the void pattern) as your
Logger
* The Logger is created as a genuine logger
* A filter is created which simply filters out everything
However what I would suggest could be a good solution for you is to
always have a logger present and log debug messages as debug and use the
other levels for what they are meant for WARNING, ERROR, etc. That way
you can easily turn the logger off in the instance you are working
with. Yes, OK you take a small speed knock but the speed knock I've had
on this is small (I'm not a speed junkie anyways).
I also agree with you, a fully featured logger is essential and
personally - I'm happy with the design, it's not too complicated you
only need to read through the docs and try it out - easy peasy lemon
squeezy.
Cheers,
Neil
--
Neil Benn
Senior Automation Engineer
Cenix BioScience
BioInnovations Zentrum
Tatzberg 47
D-01307
Dresden
Germany
Tel : +49 (0)351 4173 154
e-mail : benn at cenix-bioscience.com
Cenix Website : http://www.cenix-bioscience.com
More information about the Python-list
mailing list