41 lines
960 B
Python
41 lines
960 B
Python
|
# modules/admin/logging_config.py
|
||
|
|
||
|
import logging
|
||
|
import logging.handlers
|
||
|
import os
|
||
|
|
||
|
LOG_DIR = "logs"
|
||
|
if not os.path.exists(LOG_DIR):
|
||
|
os.makedirs(LOG_DIR)
|
||
|
|
||
|
LOG_FILE = os.path.join(LOG_DIR, "selena.log")
|
||
|
|
||
|
logging_config = {
|
||
|
"version": 1,
|
||
|
"disable_existing_loggers": False,
|
||
|
"formatters": {
|
||
|
"standard": {
|
||
|
"format": "%(asctime)s [%(levelname)s] %(name)s: %(message)s"
|
||
|
},
|
||
|
},
|
||
|
"handlers": {
|
||
|
"console": {
|
||
|
"level": "DEBUG",
|
||
|
"class": "logging.StreamHandler",
|
||
|
"formatter": "standard",
|
||
|
},
|
||
|
"file_handler": {
|
||
|
"level": "DEBUG",
|
||
|
"class": "logging.handlers.RotatingFileHandler",
|
||
|
"formatter": "standard",
|
||
|
"filename": LOG_FILE,
|
||
|
"maxBytes": 1024*1024*5, # 5 MB
|
||
|
"backupCount": 3,
|
||
|
},
|
||
|
},
|
||
|
"root": {
|
||
|
"handlers": ["console", "file_handler"],
|
||
|
"level": "DEBUG",
|
||
|
},
|
||
|
}
|