当前位置: 首页>>代码示例>>Python>>正文


Python logging.py方法代码示例

本文整理汇总了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 
开发者ID:QuarkChain,项目名称:pyquarkchain,代码行数:24,代码来源:utils.py

示例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 
开发者ID:jcyk,项目名称:gtos,代码行数:21,代码来源:logging.py

示例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) 
开发者ID:QuarkChain,项目名称:pyquarkchain,代码行数:8,代码来源:utils.py

示例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) 
开发者ID:georgia-tech-db,项目名称:eva,代码行数:8,代码来源:logging_manager.py


注:本文中的logging.py方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。