当前位置: 首页>>代码示例>>Python>>正文


Python Sentry.logging方法代码示例

本文整理汇总了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)
开发者ID:anukat2015,项目名称:udata,代码行数:53,代码来源:sentry.py

示例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)
开发者ID:odtvince,项目名称:udata,代码行数:44,代码来源:sentry.py

示例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)
开发者ID:noirbizarre,项目名称:udata,代码行数:43,代码来源:sentry.py


注:本文中的raven.contrib.flask.Sentry.logging方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。