當前位置: 首頁>>代碼示例>>Python>>正文


Python Sentry.level方法代碼示例

本文整理匯總了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)
開發者ID:anukat2015,項目名稱:udata,代碼行數:53,代碼來源:sentry.py

示例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)
開發者ID:odtvince,項目名稱:udata,代碼行數:44,代碼來源:sentry.py

示例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)
開發者ID:noirbizarre,項目名稱:udata,代碼行數:43,代碼來源:sentry.py


注:本文中的raven.contrib.flask.Sentry.level方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。