All checks were successful
git commit AiDA python develop 分支构建部署 / scheduled_deploy (push) Has been skipped
57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
import os
|
|
|
|
from app.core.config import settings
|
|
|
|
LOGGER_CONFIG_DICT = {
|
|
'version': 1,
|
|
'disable_existing_loggers': False,
|
|
'formatters': {
|
|
'simple': {
|
|
'format': '%(asctime)s %(filename)s [line:%(lineno)d] %(levelname)s %(message)s',
|
|
'datefmt': '%Y-%m-%d %H:%M:%S' # 补充日期格式,日志更易读
|
|
}
|
|
},
|
|
'handlers': {
|
|
'console': {
|
|
'class': 'logging.StreamHandler',
|
|
'level': 'INFO',
|
|
'formatter': 'simple',
|
|
'stream': 'ext://sys.stdout',
|
|
},
|
|
'info_file_handler': {
|
|
'class': 'logging.handlers.RotatingFileHandler',
|
|
'level': 'INFO',
|
|
'formatter': 'simple',
|
|
'filename': os.path.join(settings.LOGS_PATH, 'info.log'),
|
|
'maxBytes': 10485760,
|
|
'backupCount': 50,
|
|
'encoding': 'utf8',
|
|
},
|
|
'error_file_handler': {
|
|
'class': 'logging.handlers.RotatingFileHandler',
|
|
'level': 'ERROR',
|
|
'formatter': 'simple',
|
|
'filename': os.path.join(settings.LOGS_PATH, 'error.log'),
|
|
'maxBytes': 10485760,
|
|
'backupCount': 20,
|
|
'encoding': 'utf8',
|
|
},
|
|
'debug_file_handler': {
|
|
'class': 'logging.handlers.RotatingFileHandler',
|
|
'level': 'DEBUG',
|
|
'formatter': 'simple',
|
|
'filename': os.path.join(settings.LOGS_PATH, 'debug.log'),
|
|
'maxBytes': 10485760,
|
|
'backupCount': 50,
|
|
'encoding': 'utf8',
|
|
},
|
|
},
|
|
'loggers': {
|
|
'my_module': {'level': 'INFO', 'handlers': ['console'], 'propagate': 'no'}
|
|
},
|
|
'root': {
|
|
'level': 'DEBUG',
|
|
'handlers': ['error_file_handler', 'info_file_handler', 'debug_file_handler', 'console'],
|
|
},
|
|
}
|