本文整理匯總了Python中raven.contrib.flask.Sentry.logging方法的典型用法代碼示例。如果您正苦於以下問題:Python Sentry.logging方法的具體用法?Python Sentry.logging怎麽用?Python Sentry.logging使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類raven.contrib.flask.Sentry
的用法示例。
在下文中一共展示了Sentry.logging方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: init_app
# 需要導入模塊: from raven.contrib.flask import Sentry [as 別名]
# 或者: from raven.contrib.flask.Sentry import logging [as 別名]
def init_app(app):
if 'SENTRY_DSN' in app.config:
try:
from raven.contrib.celery import (
register_signal, register_logger_signal
)
from raven.contrib.flask import Sentry
except:
log.error('raven[flask] is required to use sentry')
return
sentry = Sentry()
tags = app.config['SENTRY_TAGS'] = app.config.get('SENTRY_TAGS', {})
app.config.setdefault('SENTRY_USER_ATTRS',
['slug', 'email', 'fullname'])
app.config.setdefault('SENTRY_LOGGING', 'WARNING')
log_level_name = app.config.get('SENTRY_LOGGING')
if log_level_name:
log_level = getattr(logging, log_level_name.upper())
if log_level:
sentry.logging = True
sentry.level = log_level
# Do not send HTTPExceptions
exceptions = app.config.get('RAVEN_IGNORE_EXCEPTIONS', [])
if HTTPException not in exceptions:
exceptions.append(HTTPException)
if PermissionDenied not in exceptions:
exceptions.append(PermissionDenied)
app.config['RAVEN_IGNORE_EXCEPTIONS'] = exceptions
app.config['SENTRY_PUBLIC_DSN'] = public_dsn(app.config['SENTRY_DSN'])
# Versions Management: uData and plugins versions as tags.
packages = ['udata']
packages += ['udata_{0}'.format(p) for p in app.config['PLUGINS']]
for package in packages:
version = pkg_resources.get_distribution(package).version
if version:
tags[package] = version
sentry.init_app(app)
# register a custom filter to filter out duplicate logs
register_logger_signal(sentry.client, loglevel=sentry.level)
# hook into the Celery error handler
register_signal(sentry.client)
示例2: init_app
# 需要導入模塊: from raven.contrib.flask import Sentry [as 別名]
# 或者: from raven.contrib.flask.Sentry import logging [as 別名]
def init_app(app):
if app.config['SENTRY_DSN']:
try:
from raven.contrib.celery import (
register_signal, register_logger_signal
)
from raven.contrib.flask import Sentry
except ImportError:
log.error('raven is required to use Sentry')
return
sentry = Sentry()
tags = app.config['SENTRY_TAGS']
log_level_name = app.config['SENTRY_LOGGING']
if log_level_name:
log_level = getattr(logging, log_level_name.upper())
if log_level:
sentry.logging = True
sentry.level = log_level
# Do not send HTTPExceptions
exceptions = set(app.config['SENTRY_IGNORE_EXCEPTIONS'])
for exception in IGNORED_EXCEPTIONS:
exceptions.add(exception)
app.config['SENTRY_IGNORE_EXCEPTIONS'] = list(exceptions)
app.config['SENTRY_PUBLIC_DSN'] = public_dsn(app.config['SENTRY_DSN'])
# Versions Management: uData and plugins versions as tags.
for dist in entrypoints.get_plugins_dists(app):
if dist.version:
tags[dist.project_name] = dist.version
# Do not forget udata itself
tags['udata'] = pkg_resources.get_distribution('udata').version
sentry.init_app(app)
# register a custom filter to filter out duplicate logs
register_logger_signal(sentry.client, loglevel=sentry.level)
# hook into the Celery error handler
register_signal(sentry.client)
示例3: init_app
# 需要導入模塊: from raven.contrib.flask import Sentry [as 別名]
# 或者: from raven.contrib.flask.Sentry import logging [as 別名]
def init_app(app):
if 'SENTRY_DSN' in app.config:
try:
from raven.contrib.celery import (
register_signal, register_logger_signal
)
from raven.contrib.flask import Sentry
except:
log.error('raven[flask] is required to use sentry')
return
sentry = Sentry()
app.config.setdefault('SENTRY_USER_ATTRS',
['slug', 'email', 'fullname'])
app.config.setdefault('SENTRY_LOGGING', 'WARNING')
log_level_name = app.config.get('SENTRY_LOGGING')
if log_level_name:
log_level = getattr(logging, log_level_name.upper())
if log_level:
sentry.logging = True
sentry.level = log_level
# Do not send HTTPExceptions
exceptions = app.config.get('RAVEN_IGNORE_EXCEPTIONS', [])
if HTTPException not in exceptions:
exceptions.append(HTTPException)
if PermissionDenied not in exceptions:
exceptions.append(PermissionDenied)
app.config['RAVEN_IGNORE_EXCEPTIONS'] = exceptions
app.config['SENTRY_PUBLIC_DSN'] = public_dsn(app.config['SENTRY_DSN'])
sentry.init_app(app)
# register a custom filter to filter out duplicate logs
register_logger_signal(sentry.client, loglevel=sentry.level)
# hook into the Celery error handler
register_signal(sentry.client)