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


Python logging.default_handler方法代码示例

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


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

示例1: run_mediator

# 需要导入模块: from flask import logging [as 别名]
# 或者: from flask.logging import default_handler [as 别名]
def run_mediator(port: int, remote_api, no_logging=False):
    global browser
    # reassign this variable again so that tests could mock it
    browser = remote_api
    # TODO: does not really work, I still see logs in unittests
    if no_logging:
        log = logging.getLogger('werkzeug')
        log.setLevel(logging.ERROR)
        log.disabled = True
        app.logger.disabled = True
        from flask.logging import default_handler
        app.logger.removeHandler(default_handler)
    return app.run(DEFAULT_HTTP_IFACE, port, debug=False, threaded=False) 
开发者ID:balta2ar,项目名称:brotab,代码行数:15,代码来源:brotab_mediator.py

示例2: startServer

# 需要导入模块: from flask import logging [as 别名]
# 或者: from flask.logging import default_handler [as 别名]
def startServer(self):
        self.flask_app.run(port=self.port, host="0.0.0.0")
        self.flask_app.logger.removeHandler(default_handler) 
开发者ID:ChristianTremblay,项目名称:BAC0,代码行数:5,代码来源:FlaskServer.py

示例3: setup_logging

# 需要导入模块: from flask import logging [as 别名]
# 或者: from flask.logging import default_handler [as 别名]
def setup_logging(app):
    log_formatter = logger.Formatter(
            '%(asctime)s %(levelname)8s [%(filename)s:%(lineno)d] '
            '%(client)s %(message)s')
    # log to files unless on AppEngine
    if not on_appengine():
        # Main logger
        if not (app.debug or app.config.get('TESTING')):
            handler = logging.FileHandler(
                app.config.get('LOGFILE', '/tmp/scoreboard.wsgi.log'))
            handler.setLevel(logging.INFO)
            handler.setFormatter(log_formatter)
            app.logger.addHandler(handler)
        else:
            app.logger.handlers[0].setFormatter(log_formatter)

        # Challenge logger
        handler = logging.FileHandler(
            app.config.get('CHALLENGELOG', '/tmp/scoreboard.challenge.log'))
        handler.setLevel(logging.INFO)
        handler.setFormatter(logger.Formatter(
            '%(asctime)s %(client)s %(message)s'))
        local_logger = logging.getLogger('scoreboard')
        local_logger.addHandler(handler)
        app.challenge_log = local_logger
    else:
        app.challenge_log = app.logger
        try:
            import google.cloud.logging
            from google.cloud.logging import handlers
            client = google.cloud.logging.Client()
            client.setup_logging()
            handler = handlers.CloudLoggingHandler(client)
            app.logger.addHandler(handler)
            handler.setLevel(logging.INFO)
            return app
        except ImportError as ex:
            logging.error('Failed setting up logging: %s', ex)
        if not app.logger.handlers:
            app.logger.addHandler(flask_logging.default_handler)
            app.logger.handlers[0].setFormatter(log_formatter)
            logging.getLogger().handlers[0].setFormatter(log_formatter)

    return app 
开发者ID:google,项目名称:ctfscoreboard,代码行数:46,代码来源:main.py


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