2016-12-30 21:31:43 +01:00
|
|
|
import logging
|
|
|
|
|
|
|
|
|
|
|
|
class Handler(logging.Handler):
|
|
|
|
"""A logging handler that reports errors to the analytics manager"""
|
|
|
|
def __init__(self, manager, level=logging.ERROR):
|
|
|
|
self.manager = manager
|
|
|
|
logging.Handler.__init__(self, level)
|
|
|
|
|
|
|
|
def emit(self, record):
|
2017-02-11 20:47:45 +01:00
|
|
|
# We need to call format to ensure that record.message and
|
|
|
|
# record.exc_text attributes are populated
|
|
|
|
self.format(record)
|
2017-01-29 22:47:00 +01:00
|
|
|
self.manager.send_error(record)
|