【Python Loguru】实现日志工具和日志饶接
创始人
2024-11-15 03:33:35
0

【Python Loguru】实现日志工具和日志饶接

说明

代码使用第三方库Loguru实现了logging工具,可以直接改名字后就使用,并实现了日志绕接,使用前需要先安装loguru工具。

Code

import os import json from loguru import logger  # config_file = "basic_config.json" # for production config_file = "basic_config_dev.json" # for local development  def get_logger(name: str) -> logger:     r"""     Gets a standard logger with a file sink.     Rotate when the log file is larger than 500M;      Keep the last 10 log files;     Compress the log file when it is too big.     """      current_dir = os.path.dirname(os.path.abspath(__file__))     basic_config = os.path.join(current_dir, '../config/', config_file)     with open(basic_config,"r") as f:         config = json.load(f)      log_file = config["log_file_path"] + config["project_name"].lower() + ".log"      logger.configure(handlers=[         {             "sink": log_file,             "format": "{time} - {level} - {name} - {function} - {message}",             "level": "INFO",             "rotation": "500 MB",             "retention": 10,             "compression": "zip"         }     ])      return logger  

相关内容

热门资讯

第七分钟透视!wepoker轻... 第七分钟透视!wepoker轻量版透视,(wepoker)确实是有挂,解说技巧(有挂辅助)1、第七分...
2分钟脚本!aapoker怎么... 2分钟脚本!aapoker怎么设置抽水,aapoker能控制牌吗,普及教程(有挂机密)1、aapok...
透视脚本!hhpoker透视脚... 透视脚本!hhpoker透视脚本(底牌)详细透视辅助器(有挂方法)1、下载好hhpoker透视脚本辅...
3分钟辅助挂!wpk德州局透视... 3分钟辅助挂!wpk德州局透视,(WPk)一直真的有挂(详细透视辅助插件解密)1、不需要AI权限,帮...
透视安装包!wepoker底牌... 透视安装包!wepoker底牌透视,(WePoKer)真是存在有挂(详细透视底牌辅助安装)1、玩家可...
科普攻略!hhpoker德州透... 科普攻略!hhpoker德州透视,hhpoker是真的假的,教你攻略(有挂脚本);一、hhpoker...
九分钟脚本!aapoker辅助... 九分钟脚本!aapoker辅助怎么用,aapoker公共底牌,规律教程(有挂解说)1、进入到aapo...
7分钟普及!wpk软件是真的,... 7分钟普及!wpk软件是真的,(WPk)总是真的有挂(详细透视辅助工具教程);1、用户打开应用后不用...
透视软件!wepoker黑侠辅... 透视软件!wepoker黑侠辅助器正版下载,(wepoker)一直是真的有挂(详细透视底牌辅助神器)...
透视脚本!hh poker软件... 透视脚本!hh poker软件(底牌)详细透视辅助神器(有挂科普)一、hh poker软件AI软件牌...