You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(Re)Work on find is complete pending testing but this has highlighted an issue with test_log2d.cleanup() which may impact testing in other areas besides find.
In cleanup(), logging.shutdown() does not have the anticipated effect of re-initialisinglogging. In particular, after shutdown(), logging still contains handlers which end up affecting subsequent Log instances. Thus, the order in which tests are carried out affects the test results.
This is a design feature of logging.shutdown() which is really meant to be used just before application exit: See this from stackoverflow and Python logging docs.
I will look for a solution but (as always) need to learn more about logging first.
Mike
The text was updated successfully, but these errors were encountered:
Thanks Mike and belated Happy New Year! No urgency for this as .shutdown was only intended as a utility/helper function for the testing docs and isn't a "public" part of the log2d functionality. Having said that, if you have the time and inclination to get to the bottom of things, you'll have truly mastered the built in logging module I think, and others (including me) will benefit from the sum of your learnings :)
You flatterer! The cure seems to be actually in Log.__init__. If you remove any existing handlers before adding the required ones back in, all is well.
Modify __init__ to add
while len(self.logger.handlers) > 0:
self.logger.removeHandler(self.logger.handlers[0])
just before the line for handler in self.get_handlers():
This actually fixed another couple of odd behaviours I'd seen - multiple copies of the log message on stdout being a common one.
(Re)Work on
find
is complete pending testing but this has highlighted an issue withtest_log2d.cleanup()
which may impact testing in other areas besidesfind
.In
cleanup()
,logging.shutdown()
does not have the anticipated effect of re-initialisinglogging
. In particular, aftershutdown()
, logging still contains handlers which end up affecting subsequentLog
instances. Thus, the order in which tests are carried out affects the test results.This is a design feature of
logging.shutdown()
which is really meant to be used just before application exit: See this from stackoverflow and Python logging docs.I will look for a solution but (as always) need to learn more about logging first.
Mike
The text was updated successfully, but these errors were encountered: