Closed amitschang closed 2 months ago
Good catch! This can be handled by adding the appropriate code to remove the logger in BaseInterface.__del__
.
Want me to quickly handle it?
Actually, I think it's more a question of not adding new handlers after getLogger
etc.
yes, I would advocate for not adding handlers in the base
I think it's totally ok to add them in the base, just not if they already exist as desired.
Also, the point of the name
attr is to differentiate between instances.
The base interface does some logging setup, but in case there are two things of the same type or name, we can get duplicates of the handler, for example, if
MySensor
is descendent ofBaseInterface
what we see is:
because a reconfigure creates new instances in a running process (so that the logger sticks around) , this will likely lead to a lot of increasingly duplicate logs.
It's nice to have the
logger
in there, but I suspect that most cases we'll want to set up the handlers/formatters in root a certain way and have the loggers derive from there, and otherwise they should probably be set explicitly by the user - so theBaseInterface
could prob refrain from setting the handler at all.