yukilog/main.py

38 lines
1.2 KiB
Python
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from yukilog import get_logger
from t_module import print_message
def test_logger(logger):
logger.success("这是一个成功的消息")
logger.trace("这是一个跟踪消息")
logger.debug("这是一个调试消息")
logger.info("这是一个信息消息")
logger.warning("这是一个警告消息")
logger.error("这是一个错误消息")
logger.critical("这是一个严重错误消息")
def main():
print("Normal Style")
logger = get_logger("INFO")
test_logger(logger)
print("Debug Style")
logger.remove() # Remove the default handler
logger = get_logger("DEBUG")
test_logger(logger)
print_message(logger)
# 修改现有日志级别的颜色和图标
logger.level("TRACE", color="<cyan>", icon="🔍")
logger.level("DEBUG", color="<blue>", icon="🐛")
logger.level("INFO", color="<green>", icon="")
logger.level("SUCCESS", color="<bold><green>", icon="✔️")
logger.level("WARNING", color="<yellow>", icon="⚠️")
logger.level("ERROR", color="<red>", icon="")
logger.level("CRITICAL", color="<bold><red>", icon="🔥")
test_logger(logger)
if __name__ == "__main__":
main()