本文整理匯總了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)
示例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)
示例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