本文整理汇总了Python中raven.contrib.flask.Sentry.level方法的典型用法代码示例。如果您正苦于以下问题:Python Sentry.level方法的具体用法?Python Sentry.level怎么用?Python Sentry.level使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类raven.contrib.flask.Sentry
的用法示例。
在下文中一共展示了Sentry.level方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_app
# 需要导入模块: from raven.contrib.flask import Sentry [as 别名]
# 或者: from raven.contrib.flask.Sentry import level [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 level [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 level [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)