add stat files.
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
import logging
|
||||
import os
|
||||
import inspect
|
||||
|
||||
# MySQL 配置
|
||||
db_config = {
|
||||
@ -9,7 +11,14 @@ db_config = {
|
||||
}
|
||||
|
||||
# 设置日志配置
|
||||
def setup_logging(log_filename):
|
||||
def setup_logging(log_filename=None):
|
||||
# 如果未传入 log_filename,则使用当前脚本名称作为日志文件名
|
||||
if log_filename is None:
|
||||
# 获取调用 setup_logging 的脚本文件名
|
||||
caller_frame = inspect.stack()[1]
|
||||
caller_filename = os.path.splitext(os.path.basename(caller_frame.filename))[0]
|
||||
log_filename = './log/' + caller_filename + '.log'
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s [%(filename)s:%(lineno)d] - %(message)s',
|
||||
handlers=[
|
||||
logging.FileHandler(log_filename),
|
||||
|
||||
Reference in New Issue
Block a user