Loggers and reloads
Diez B. Roggisch
deetsNOSPAM at web.de
Wed May 26 17:49:08 EDT 2004
Francois Bouffard wrote:
> The problem is that each time I reload my module, a new logger object
> seems to be created, and the old one is not deleted. Both the new and
> the old object are still working, so that each log message is
> repeated; in general, if I did N reloads of my module, each message is
> repeated N+1 times.
The problem would disappear if you wrote a small testscript that uses your
module and execeted that from scratch, instead of reloading the module -
which might also create other state related problems.
But if you insist on using your module, you could place the logger
initialization into another module or encapsulate it in a function that you
call manually - but only once. As the logging systems state is kept in the
not-reloaded logging module, that should rid you of your problem. I bet it
would also be possible to check if for a given logger already a handler is
registered, and refuse to add another one.
--
Regards,
Diez B. Roggisch
More information about the Python-list
mailing list