本文整理汇总了Python中logging.py方法的典型用法代码示例。如果您正苦于以下问题:Python logging.py方法的具体用法?Python logging.py怎么用?Python logging.py使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logging
的用法示例。
在下文中一共展示了logging.py方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: findCaller
# 需要导入模块: import logging [as 别名]
# 或者: from logging import py [as 别名]
def findCaller(self, stack_info=False):
frame = sys._getframe(2)
f_to_skip = {
func for func in dir(Logger) if callable(getattr(Logger, func))
}.union({func for func in dir(QKCLogger) if callable(getattr(QKCLogger, func))})
while frame:
code = frame.f_code
if _LOGGING_FILE_PREFIX not in code.co_filename and (
"utils.py" not in code.co_filename or code.co_name not in f_to_skip
):
if not stack_info:
return (code.co_filename, frame.f_lineno, code.co_name, "")
else:
sinfo = None
if stack_info:
out = io.StringIO()
out.write(u"Stack (most recent call last):\n")
traceback.print_stack(frame, file=out)
sinfo = out.getvalue().rstrip(u"\n")
return (code.co_filename, frame.f_lineno, code.co_name, sinfo)
frame = frame.f_back
示例2: init_logger
# 需要导入模块: import logging [as 别名]
# 或者: from logging import py [as 别名]
def init_logger(log_name=None, log_file=None):
"""
Adopted from OpenNMT-py:
https://github.com/OpenNMT/OpenNMT-py/blob/master/onmt/utils/logging.py
"""
log_format = logging.Formatter("[%(asctime)s %(levelname)s] %(message)s")
logger = logging.getLogger(log_name)
logger.setLevel(logging.INFO)
console_handler = logging.StreamHandler()
console_handler.setFormatter(log_format)
logger.handlers = [console_handler]
if log_file and log_file != '':
file_handler = logging.FileHandler(log_file)
file_handler.setFormatter(log_format)
logger.addHandler(file_handler)
return logger
示例3: trace
# 需要导入模块: import logging [as 别名]
# 或者: from logging import py [as 别名]
def trace(self, msg: str, *args, **kwargs) -> None:
"""
log as debug for now
see https://github.com/ethereum/py-evm/blob/master/eth/tools/logging.py
"""
self.debug(msg, *args, **kwargs)
示例4: setEffectiveLevel
# 需要导入模块: import logging [as 别名]
# 或者: from logging import py [as 别名]
def setEffectiveLevel(self, level: LoggingLevel):
# Note: pytest logging level cannot be higher than WARNING
# https://github.com/segevfiner/pytest/blob/master/
# _pytest/logging.py#L246
self._LOG.setLevel(level.value)