Skip to content

Instantly share code, notes, and snippets.

@ffeast
Created October 30, 2017 16:19
Show Gist options
  • Save ffeast/972d5df723eb6ed68d0c43ac84d0fa6c to your computer and use it in GitHub Desktop.
Save ffeast/972d5df723eb6ed68d0c43ac84d0fa6c to your computer and use it in GitHub Desktop.
Trace logging configuration
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