Created
October 30, 2017 16:19
-
-
Save ffeast/972d5df723eb6ed68d0c43ac84d0fa6c to your computer and use it in GitHub Desktop.
Trace logging configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import sys | |
# Traces what's updating the logging configuration | |
# https://stackoverflow.com/questions/28694540/python-default-logger-disabled | |
def get_disabled(self): | |
return self._disabled | |
def set_disabled(self, disabled): | |
frame = sys._getframe(1) | |
if disabled: | |
print('{}:{} disabled the {} logger'.format( | |
frame.f_code.co_filename, frame.f_lineno, self.name)) | |
self._disabled = disabled | |
logging.Logger.disabled = property(get_disabled, set_disabled) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment