import{_ as i,o as a,c as h,a7 as k}from"./chunks/framework._avq4Ty7.js";const d=JSON.parse('{"title":"liteyuki.log","description":"","frontmatter":{"title":"liteyuki.log"},"headers":[],"relativePath":"dev/api/log.md","filePath":"zh/dev/api/log.md","lastUpdated":null}'),l={name:"dev/api/log.md"};function t(n,s,p,e,E,r){return a(),h("div",null,s[0]||(s[0]=[k(`
liteyuki.log
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/7/27 上午9:12 @Author : snowykami @Email : snowykami@outlook.com @File : log.py @Software: PyCharm
get_format(level: str) -> str
说明: 获取日志格式
参数:
- level: 日志等级
def get_format(level: str) -> str:
if level == 'DEBUG':
return debug_format
else:
return default_format
init_log(config: dict)
说明: 在语言加载完成后执行
参数:
- config: 配置
def init_log(config: dict):
global logger
level = config.get('log_level', 'DEBUG')
logger.remove()
logger.add(sys.stdout, level=level, diagnose=False, format=get_format(level))
show_icon = config.get('log_icon', True)
logger.level('DEBUG', color='<blue>', icon=f"{('🐛' if show_icon else '')}")
logger.level('INFO', color='<normal>', icon=f"{('ℹ️' if show_icon else '')}")
logger.level('SUCCESS', color='<green>', icon=f"{('✅' if show_icon else '')}")
logger.level('WARNING', color='<yellow>', icon=f"{('⚠️' if show_icon else '')}")
logger.level('ERROR', color='<red>', icon=f"{('⭕' if show_icon else '')}")
logger.level('CRITICAL', color='<red>', icon=f"{('❌' if show_icon else '')}")
logger.level('TRACE', color='<cyan>', icon=f"{('🔍' if show_icon else '')}")
logger.bind()