kinit/kinit-api/core/logger.py
ktianc 2ba2738107 版本更新:
1. 新增(kinit-api,kinit-admin):支持发送邮箱通知
2. 优化(kinit-api):core/crud.py 优化
2023-03-30 15:56:47 +08:00

30 lines
963 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

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.

import os
import time
from loguru import logger
from application.settings import BASE_DIR
"""
# 日志简单配置
# 具体其他配置 可自行参考 https://github.com/Delgan/loguru
"""
# 移除控制台输出
logger.remove(handler_id=None)
log_path = os.path.join(BASE_DIR, 'logs')
if not os.path.exists(log_path):
os.mkdir(log_path)
log_path_info = os.path.join(log_path, f'info_{time.strftime("%Y-%m-%d")}.log')
log_path_error = os.path.join(log_path, f'error_{time.strftime("%Y-%m-%d")}.log')
info = logger.add(log_path_info, rotation="00:00", retention="3 days", enqueue=True, encoding="UTF-8", level="INFO")
error = logger.add(log_path_error, rotation="00:00", retention="3 days", enqueue=True, encoding="UTF-8", level="ERROR")
if __name__ == '__main__':
print(BASE_DIR)
# logger.info("1")
retry: int = 1
logger.error("未从Redis中获取到配置信息正在重新更新配置信息重试次数{}".format(retry))