當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。