本文整理匯總了Python中raven.contrib.django.handlers.SentryHandler類的典型用法代碼示例。如果您正苦於以下問題:Python SentryHandler類的具體用法?Python SentryHandler怎麽用?Python SentryHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了SentryHandler類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_record_none_exc_info
def test_record_none_exc_info(self):
# sys.exc_info can return (None, None, None) if no exception is being
# handled anywhere on the stack. See:
# http://docs.python.org/library/sys.html#sys.exc_info
record = logging.LogRecord(
"foo", logging.INFO, pathname=None, lineno=None, msg="test", args=(), exc_info=(None, None, None)
)
handler = SentryHandler()
handler.emit(record)
self.assertEquals(len(self.raven.events), 1)
event = self.raven.events.pop(0)
self.assertEquals(event["message"], "test")
示例2: SentryHandler
SENTRY_CACHE_BACKEND = 'default'
EMAIL_SUBJECT_PREFIX = '[Sentry] '
# Configure logging
from raven.conf import setup_logging
from raven.contrib.django.handlers import SentryHandler
import logging
# Configure root logger
logger = logging.getLogger()
logger.setLevel(logging.INFO)
handler = logging.StreamHandler()
handler.setLevel(logging.INFO)
logger.addHandler(handler)
# Disable django.request as it's generally useless
logger = logging.getLogger('django.request')
logger.propagate = False
logger.addHandler(handler)
# Configure default sentry logging
sentry_handler = SentryHandler()
sentry_handler.setLevel(logging.ERROR)
setup_logging(sentry_handler)
# Configure celery
import djcelery
djcelery.setup_loader()