The logging docs say that calling the logging.disable(lvl)
method can "temporarily throttle logging output down across the whole application," but I'm having trouble finding the "temporarily." Take, for example, the following script:
import logging
logging.disable(logging.CRITICAL)
logging.warning("test")
# Something here
logging.warning("test")
So far, I haven't been able to find the Something here
that will re-enable the logging system as a whole and allow the second warning
to get through. Is there a reverse to disable()
?
Based on the answer by @unutbu, I created a context manager: