本文整理汇总了Python中flask.logging.create_logger方法的典型用法代码示例。如果您正苦于以下问题:Python logging.create_logger方法的具体用法?Python logging.create_logger怎么用?Python logging.create_logger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask.logging
的用法示例。
在下文中一共展示了logging.create_logger方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: logger
# 需要导入模块: from flask import logging [as 别名]
# 或者: from flask.logging import create_logger [as 别名]
def logger(self):
"""A :class:`logging.Logger` object for this application. The
default configuration is to log to stderr if the application is
in debug mode. This logger can be used to (surprise) log messages.
Here some examples::
app.logger.debug('A value for debugging')
app.logger.warning('A warning occurred (%d apples)', 42)
app.logger.error('An error occurred')
.. versionadded:: 0.3
"""
if self._logger and self._logger.name == self.logger_name:
return self._logger
with _logger_lock:
if self._logger and self._logger.name == self.logger_name:
return self._logger
from flask.logging import create_logger
self._logger = rv = create_logger(self)
return rv
示例2: logger
# 需要导入模块: from flask import logging [as 别名]
# 或者: from flask.logging import create_logger [as 别名]
def logger(self):
"""A :class:`logging.Logger` object for this application. The
default configuration is to log to stderr if the application is
in debug mode. This logger can be used to (surprise) log messages.
Here some examples::
app.logger.debug('A value for debugging')
app.logger.warning('A warning ocurred (%d apples)', 42)
app.logger.error('An error occoured')
.. versionadded:: 0.3
"""
if self._logger and self._logger.name == self.logger_name:
return self._logger
with _logger_lock:
if self._logger and self._logger.name == self.logger_name:
return self._logger
from flask.logging import create_logger
self._logger = rv = create_logger(self)
return rv
示例3: setup_logs
# 需要导入模块: from flask import logging [as 别名]
# 或者: from flask.logging import create_logger [as 别名]
def setup_logs(args):
"""
Initialize the api loggers.
Args:
args: dict containing the configuration options.
"""
flask_logging.create_logger = lambda app: logging.getLogger(app.logger_name)
logger = logging.getLogger("werkzeug")
if logger:
logger.setLevel(logging.ERROR)
level = [logging.WARNING, logging.INFO, logging.DEBUG][
min(args.get("verbose", 1), 2)
]
# Handle ERROR level with ExceptionHandler
internal_error_log = ExceptionHandler()
internal_error_log.setLevel(logging.ERROR)
log.root.setLevel(level)
log.root.addHandler(internal_error_log)
# Handle INFO level with FunctionLoggingHandler
stats_log = FunctionLoggingHandler()
stats_log.setLevel(logging.INFO)
log.root.addHandler(stats_log)