# -*- coding: utf-8 -*-"""flask.logging~~~~~~~~~~~~~:copyright: © 2010 by the Pallets team.:license: BSD, see LICENSE for more details."""from __future__ import absolute_importimport loggingimport sysfrom werkzeug.local import LocalProxyfrom .globals import request@LocalProxydef wsgi_errors_stream():"""Find the most appropriate error stream for the application. If a requestis active, log to ``wsgi.errors``, otherwise use ``sys.stderr``.If you configure your own :class:`logging.StreamHandler`, you may want touse this for the stream. If you are using file or dict configuration andcan't import this directly, you can refer to it as``ext://flask.logging.wsgi_errors_stream``."""return request.environ['wsgi.errors'] if request else sys.stderrdef has_level_handler(logger):"""Check if there is a handler in the logging chain that will handle thegiven logger's :meth:`effective level <~logging.Logger.getEffectiveLevel>`."""level = logger.getEffectiveLevel()current = loggerwhile current:if any(handler.level <= level for handler in current.handlers):return Trueif not current.propagate:breakcurrent = current.parentreturn False#: Log messages to :func:`~flask.logging.wsgi_errors_stream` with the format#: ``[%(asctime)s] %(levelname)s in %(module)s: %(message)s``.default_handler = logging.StreamHandler(wsgi_errors_stream)default_handler.setFormatter(logging.Formatter('[%(asctime)s] %(levelname)s in %(module)s: %(message)s'))def create_logger(app):"""Get the ``'flask.app'`` logger and configure it if needed.When :attr:`~flask.Flask.debug` is enabled, set the logger level to:data:`logging.DEBUG` if it is not set.If there is no handler for the logger's effective level, add a:class:`~logging.StreamHandler` for:func:`~flask.logging.wsgi_errors_stream` with a basic format."""logger = logging.getLogger('flask.app')if app.debug and logger.level == logging.NOTSET:logger.setLevel(logging.DEBUG)if not has_level_handler(logger):logger.addHandler(default_handler)return logger
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。