diff options
| author | Jannis Leidel | 2013-11-29 05:46:34 -0800 |
|---|---|---|
| committer | Jannis Leidel | 2013-11-29 05:46:34 -0800 |
| commit | c12de857b96960bdb506d084b186b62e0c4bd292 (patch) | |
| tree | 1e482b4b41e6bc04743052b02c329c8db1984270 /debug_toolbar/panels/logging.py | |
| parent | a7dbc61ec4b4932a570d538b23a3ddd1d46203d4 (diff) | |
| parent | ffe4c5d685fa2d8d2a23673f801eef6fa1d96b97 (diff) | |
| download | django-debug-toolbar-c12de857b96960bdb506d084b186b62e0c4bd292.tar.bz2 | |
Merge pull request #487 from aaugustin/remove-logbook
Remove support for logbook.
Diffstat (limited to 'debug_toolbar/panels/logging.py')
| -rw-r--r-- | debug_toolbar/panels/logging.py | 35 |
1 files changed, 4 insertions, 31 deletions
diff --git a/debug_toolbar/panels/logging.py b/debug_toolbar/panels/logging.py index f07281b..2dfc7a1 100644 --- a/debug_toolbar/panels/logging.py +++ b/debug_toolbar/panels/logging.py @@ -68,40 +68,13 @@ class ThreadTrackingHandler(logging.Handler): self.collector.add_record(record) +# We don't use enable/disable_instrumentation because logging is global. +# We can't add thread-local logging handlers. Hopefully logging is cheap. + collector = LogCollector() logging_handler = ThreadTrackingHandler(collector) logging.root.setLevel(logging.NOTSET) -logging.root.addHandler(logging_handler) # register with logging - -# We don't use enable/disable_instrumentation because we can't make these -# functions thread-safe and (hopefully) logging isn't too expensive. - -try: - import logbook - logbook_supported = True -except ImportError: - # logbook support is optional, so fail silently - logbook_supported = False - -if logbook_supported: - class LogbookThreadTrackingHandler(logbook.handlers.Handler): - def __init__(self, collector): - logbook.handlers.Handler.__init__(self, bubble=True) - self.collector = collector - - def emit(self, record): - record = { - 'message': record.message, - 'time': record.time, - 'level': record.level_name, - 'file': record.filename, - 'line': record.lineno, - 'channel': record.channel, - } - self.collector.add_record(record) - - logbook_handler = LogbookThreadTrackingHandler(collector) - logbook_handler.push_application() # register with logbook +logging.root.addHandler(logging_handler) class LoggingPanel(Panel): |
