當前位置: 首頁>>代碼示例>>Python>>正文


Python logzero.loglevel方法代碼示例

本文整理匯總了Python中logzero.loglevel方法的典型用法代碼示例。如果您正苦於以下問題:Python logzero.loglevel方法的具體用法?Python logzero.loglevel怎麽用?Python logzero.loglevel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在logzero的用法示例。


在下文中一共展示了logzero.loglevel方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_api_loglevel

# 需要導入模塊: import logzero [as 別名]
# 或者: from logzero import loglevel [as 別名]
def test_api_loglevel(capsys):
    """
    Should reconfigure the internal logger loglevel
    """
    logzero.reset_default_logger()
    temp = tempfile.NamedTemporaryFile()
    try:
        logzero.logfile(temp.name)
        logzero.logger.info("info1")
        logzero.loglevel(logging.WARN)
        logzero.logger.info("info2")
        logzero.logger.warn("warn1")

        with open(temp.name) as f:
            content = f.read()
            assert "] info1" in content
            assert "] info2" not in content
            assert "] warn1" in content

    finally:
        temp.close() 
開發者ID:metachris,項目名稱:logzero,代碼行數:23,代碼來源:test_new_api.py

示例2: test_api_loglevel_custom_handlers

# 需要導入模塊: import logzero [as 別名]
# 或者: from logzero import loglevel [as 別名]
def test_api_loglevel_custom_handlers(capsys):
    """
    Should reconfigure the internal logger loglevel and custom handlers
    """
    logzero.reset_default_logger()
    # TODO
    pass
    # temp = tempfile.NamedTemporaryFile()
    # try:
    #     logzero.logfile(temp.name)
    #     logzero.logger.info("info1")
    #     logzero.loglevel(logging.WARN)
    #     logzero.logger.info("info2")
    #     logzero.logger.warn("warn1")

    #     with open(temp.name) as f:
    #         content = f.read()
    #         assert "] info1" in content
    #         assert "] info2" not in content
    #         assert "] warn1" in content

    # finally:
    #     temp.close() 
開發者ID:metachris,項目名稱:logzero,代碼行數:25,代碼來源:test_new_api.py

示例3: get_logger

# 需要導入模塊: import logzero [as 別名]
# 或者: from logzero import loglevel [as 別名]
def get_logger(log_dir, loglevel=logging.INFO, tensorboard_dir=None):
    from logzero import logger

    if not Path(log_dir).exists():
        Path(log_dir).mkdir(parents=True)
    logzero.loglevel(loglevel)
    logzero.logfile(log_dir + '/logfile')

    if tensorboard_dir is not None:
        if not Path(tensorboard_dir).exists():
            Path(tensorboard_dir).mkdir(parents=True)
        writer = SummaryWriter(tensorboard_dir)

        return logger, writer

    return logger 
開發者ID:lyakaap,項目名稱:Landmark2019-1st-and-3rd-Place-Solution,代碼行數:18,代碼來源:utils.py

示例4: test_api_logfile_custom_loglevel

# 需要導入模塊: import logzero [as 別名]
# 或者: from logzero import loglevel [as 別名]
def test_api_logfile_custom_loglevel():
    """
    logzero.logfile(..) should be able to use a custom loglevel
    """
    logzero.reset_default_logger()
    temp = tempfile.NamedTemporaryFile()
    try:
        # Set logfile with custom loglevel
        logzero.logfile(temp.name, loglevel=logging.WARN)
        logzero.logger.info("info1")
        logzero.logger.warn("warn1")

        # If setting a loglevel with logzero.loglevel(..) it will not overwrite
        # the custom loglevel of the file handler
        logzero.loglevel(logging.INFO)
        logzero.logger.info("info2")
        logzero.logger.warn("warn2")

        with open(temp.name) as f:
            content = f.read()
            assert "] info1" not in content
            assert "] warn1" in content
            assert "] info2" not in content
            assert "] warn2" in content

    finally:
        temp.close() 
開發者ID:metachris,項目名稱:logzero,代碼行數:29,代碼來源:test_new_api.py

示例5: write

# 需要導入模塊: import logzero [as 別名]
# 或者: from logzero import loglevel [as 別名]
def write(Message,*v,**d):
    logzero.logfile(log_path)
    logzero.loglevel(logging.INFO)
    logger.info(str(Message))
    if v:
        for msg in v:
            logger.info('%s\n' %msg)
    if d:
        for k in d:
            logger.info('%s\n' %d[k]) 
開發者ID:wylok,項目名稱:sparrow,代碼行數:12,代碼來源:loging.py


注:本文中的logzero.loglevel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。