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


Python logging.LoggingIntegration方法代码示例

本文整理汇总了Python中sentry_sdk.integrations.logging.LoggingIntegration方法的典型用法代码示例。如果您正苦于以下问题:Python logging.LoggingIntegration方法的具体用法?Python logging.LoggingIntegration怎么用?Python logging.LoggingIntegration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sentry_sdk.integrations.logging的用法示例。


在下文中一共展示了logging.LoggingIntegration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_logging

# 需要导入模块: from sentry_sdk.integrations import logging [as 别名]
# 或者: from sentry_sdk.integrations.logging import LoggingIntegration [as 别名]
def test_logging(sentry_init, capture_events):
    sentry_init(
        integrations=[FalconIntegration(), LoggingIntegration(event_level="ERROR")]
    )

    logger = logging.getLogger()

    app = falcon.API()

    class Resource:
        def on_get(self, req, resp):
            logger.error("hi")
            resp.media = "ok"

    app.add_route("/", Resource())

    events = capture_events()

    client = falcon.testing.TestClient(app)
    client.simulate_get("/")

    (event,) = events
    assert event["level"] == "error" 
开发者ID:getsentry,项目名称:sentry-python,代码行数:25,代码来源:test_falcon.py

示例2: test_logging

# 需要导入模块: from sentry_sdk.integrations import logging [as 别名]
# 或者: from sentry_sdk.integrations.logging import LoggingIntegration [as 别名]
def test_logging(sentry_init, capture_events, app):
    # ensure that Flask's logger magic doesn't break ours
    sentry_init(
        integrations=[
            flask_sentry.FlaskIntegration(),
            LoggingIntegration(event_level="ERROR"),
        ]
    )

    @app.route("/")
    def index():
        app.logger.error("hi")
        return "ok"

    events = capture_events()

    client = app.test_client()
    client.get("/")

    (event,) = events
    assert event["level"] == "error" 
开发者ID:getsentry,项目名称:sentry-python,代码行数:23,代码来源:test_flask.py

示例3: test_logging_filters

# 需要导入模块: from sentry_sdk.integrations import logging [as 别名]
# 或者: from sentry_sdk.integrations.logging import LoggingIntegration [as 别名]
def test_logging_filters(sentry_init, capture_events):
    sentry_init(integrations=[LoggingIntegration()], default_integrations=False)
    events = capture_events()

    should_log = False

    class MyFilter(logging.Filter):
        def filter(self, record):
            return should_log

    logger.addFilter(MyFilter())
    logger.error("hi")

    assert not events

    should_log = True
    logger.error("hi")

    (event,) = events
    assert event["logentry"]["message"] == "hi" 
开发者ID:getsentry,项目名称:sentry-python,代码行数:22,代码来源:test_logging.py

示例4: test_logging

# 需要导入模块: from sentry_sdk.integrations import logging [as 别名]
# 或者: from sentry_sdk.integrations.logging import LoggingIntegration [as 别名]
def test_logging(sentry_init, capture_events, app, get_client):
    # ensure that Bottle's logger magic doesn't break ours
    sentry_init(
        integrations=[
            bottle_sentry.BottleIntegration(),
            LoggingIntegration(event_level="ERROR"),
        ]
    )

    @app.route("/")
    def index():
        app.logger.error("hi")
        return "ok"

    events = capture_events()

    client = get_client()
    client.get("/")

    (event,) = events
    assert event["level"] == "error" 
开发者ID:getsentry,项目名称:sentry-python,代码行数:23,代码来源:test_bottle.py

示例5: init_sentry

# 需要导入模块: from sentry_sdk.integrations import logging [as 别名]
# 或者: from sentry_sdk.integrations.logging import LoggingIntegration [as 别名]
def init_sentry():
    distribution = get_distribution("MozPhab")

    sentry_logging = LoggingIntegration(
        level=logging.INFO,
        event_level=None,
        # The default event_level is logging.ERROR, which will report any
        # "logging.error(...)" call to Sentry.  However, we respond to
        # incorrect usage with "logging.error(...)" messages, which we don't
        # want to report to Sentry.
    )
    sentry_sdk.init(
        dsn="https://e8a2a97b86c7472f9308186547aebfa2@sentry.prod.mozaws.net/502",
        integrations=[sentry_logging],
        release=distribution.version,
    ) 
开发者ID:mozilla-conduit,项目名称:review,代码行数:18,代码来源:sentry.py

示例6: test_integration_scoping

# 需要导入模块: from sentry_sdk.integrations import logging [as 别名]
# 或者: from sentry_sdk.integrations.logging import LoggingIntegration [as 别名]
def test_integration_scoping(sentry_init, capture_events):
    logger = logging.getLogger("test_basics")

    # This client uses the logging integration
    logging_integration = LoggingIntegration(event_level=logging.WARNING)
    sentry_init(default_integrations=False, integrations=[logging_integration])
    events = capture_events()
    logger.warning("This is a warning")
    assert len(events) == 1

    # This client does not
    sentry_init(default_integrations=False)
    events = capture_events()
    logger.warning("This is not a warning")
    assert not events 
开发者ID:getsentry,项目名称:sentry-python,代码行数:17,代码来源:test_basics.py

示例7: test_logging_works_with_many_loggers

# 需要导入模块: from sentry_sdk.integrations import logging [as 别名]
# 或者: from sentry_sdk.integrations.logging import LoggingIntegration [as 别名]
def test_logging_works_with_many_loggers(sentry_init, capture_events, logger):
    sentry_init(integrations=[LoggingIntegration(event_level="ERROR")])
    events = capture_events()

    logger.info("bread")
    logger.critical("LOL")
    (event,) = events
    assert event["level"] == "fatal"
    assert not event["logentry"]["params"]
    assert event["logentry"]["message"] == "LOL"
    assert any(crumb["message"] == "bread" for crumb in event["breadcrumbs"]) 
开发者ID:getsentry,项目名称:sentry-python,代码行数:13,代码来源:test_logging.py

示例8: test_logging_extra_data

# 需要导入模块: from sentry_sdk.integrations import logging [as 别名]
# 或者: from sentry_sdk.integrations.logging import LoggingIntegration [as 别名]
def test_logging_extra_data(sentry_init, capture_events):
    sentry_init(integrations=[LoggingIntegration()], default_integrations=False)
    events = capture_events()

    logger.info("bread", extra=dict(foo=42))
    logger.critical("lol", extra=dict(bar=69))

    (event,) = events

    assert event["level"] == "fatal"
    assert event["extra"] == {"bar": 69}
    assert any(
        crumb["message"] == "bread" and crumb["data"] == {"foo": 42}
        for crumb in event["breadcrumbs"]
    ) 
开发者ID:getsentry,项目名称:sentry-python,代码行数:17,代码来源:test_logging.py

示例9: test_logging_stack

# 需要导入模块: from sentry_sdk.integrations import logging [as 别名]
# 或者: from sentry_sdk.integrations.logging import LoggingIntegration [as 别名]
def test_logging_stack(sentry_init, capture_events):
    sentry_init(integrations=[LoggingIntegration()], default_integrations=False)
    events = capture_events()

    logger.error("first", exc_info=True)
    logger.error("second")

    event_with, event_without, = events

    assert event_with["level"] == "error"
    assert event_with["threads"]["values"][0]["stacktrace"]["frames"]

    assert event_without["level"] == "error"
    assert "threads" not in event_without 
开发者ID:getsentry,项目名称:sentry-python,代码行数:16,代码来源:test_logging.py

示例10: test_logging_level

# 需要导入模块: from sentry_sdk.integrations import logging [as 别名]
# 或者: from sentry_sdk.integrations.logging import LoggingIntegration [as 别名]
def test_logging_level(sentry_init, capture_events):
    sentry_init(integrations=[LoggingIntegration()], default_integrations=False)
    events = capture_events()

    logger.setLevel(logging.WARNING)
    logger.error("hi")
    (event,) = events
    assert event["level"] == "error"
    assert event["logentry"]["message"] == "hi"

    del events[:]

    logger.setLevel(logging.ERROR)
    logger.warning("hi")
    assert not events 
开发者ID:getsentry,项目名称:sentry-python,代码行数:17,代码来源:test_logging.py

示例11: test_transport_infinite_loop

# 需要导入模块: from sentry_sdk.integrations import logging [as 别名]
# 或者: from sentry_sdk.integrations.logging import LoggingIntegration [as 别名]
def test_transport_infinite_loop(httpserver, request):
    httpserver.serve_content("ok", 200)

    client = Client(
        "http://foobar@{}/123".format(httpserver.url[len("http://") :]),
        debug=True,
        # Make sure we cannot create events from our own logging
        integrations=[LoggingIntegration(event_level=logging.DEBUG)],
    )

    with Hub(client):
        capture_message("hi")
        client.flush()

    assert len(httpserver.requests) == 1 
开发者ID:getsentry,项目名称:sentry-python,代码行数:17,代码来源:test_transport.py

示例12: setup_logging

# 需要导入模块: from sentry_sdk.integrations import logging [as 别名]
# 或者: from sentry_sdk.integrations.logging import LoggingIntegration [as 别名]
def setup_logging():
    sentry_logging = LoggingIntegration(
        level=logging.INFO,  # Capture info and above as breadcrumbs
        event_level=logging.WARNING,  # Send errors as events
    )
    sentry_sdk.init(
        settings.SENTRY_URL,
        integrations=[sentry_logging],
        environment=settings.SENTRY_ENVIRONMENT,
    ) 
开发者ID:JosXa,项目名称:BotListBot,代码行数:12,代码来源:main.py

示例13: configure_sentry_logging

# 需要导入模块: from sentry_sdk.integrations import logging [as 别名]
# 或者: from sentry_sdk.integrations.logging import LoggingIntegration [as 别名]
def configure_sentry_logging(sentry_url):
    sentry_logging = LoggingIntegration(
        level=logging.WARNING,  # Capture warning and above as breadcrumbs
        event_level=logging.ERROR,  # Send errors as events
    )
    sentry_sdk.init(dsn=sentry_url, integrations=[sentry_logging], release=__version__) 
开发者ID:Scille,项目名称:parsec-cloud,代码行数:8,代码来源:logging.py

示例14: setup_log

# 需要导入模块: from sentry_sdk.integrations import logging [as 别名]
# 或者: from sentry_sdk.integrations.logging import LoggingIntegration [as 别名]
def setup_log(sentry_url, print_errors):
    global logger, production
    sentry_logging = LoggingIntegration(
        level=logging.INFO,
        event_level=logging.INFO
    )
    sentry_sdk.init(dsn=sentry_url, integrations=[sentry_logging])
    logger = logging.getLogger(__name__)
    p_errors = print_errors
    production = True 
开发者ID:RiiConnect24,项目名称:File-Maker,代码行数:12,代码来源:utils.py

示例15: setup_sentry

# 需要导入模块: from sentry_sdk.integrations import logging [as 别名]
# 或者: from sentry_sdk.integrations.logging import LoggingIntegration [as 别名]
def setup_sentry(enable_flask_integration: bool = False) -> None:
    sentry_dsn = os.environ.get("SENTRY_DSN")
    environment = os.environ.get("DEPLOY_ENV")
    if sentry_dsn is not None:
        log.info("Initializing sentry", dsn=sentry_dsn)
        integrations: List[Any] = [LoggingIntegration(level=logging.INFO, event_level=None)]
        if enable_flask_integration:
            integrations.append(FlaskIntegration())
        sentry_sdk.init(
            dsn=sentry_dsn,
            integrations=integrations,
            release=pkg_resources.get_distribution("raiden-services").version,
            environment=environment,
        ) 
开发者ID:raiden-network,项目名称:raiden-services,代码行数:16,代码来源:cli.py


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