本文整理汇总了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()
示例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()
示例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
示例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()
示例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])