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