Skip to content

Commit fb3e7c0

Browse files
committed
replace logging file with inline dict
1 parent a6fe000 commit fb3e7c0

1 file changed

Lines changed: 42 additions & 6 deletions

File tree

src/flow_preprocessor/utils/logging/preprocessing_logger.py

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,55 @@
44

55
import os
66
import logging.config
7-
import yaml
87

98
# Ensure log directory exists
109
LOG_DIR = "logs"
1110
if not os.path.exists(LOG_DIR):
1211
os.makedirs(LOG_DIR)
1312

13+
logging_config = {
14+
'version': 1,
15+
'disable_existing_loggers': False,
16+
'formatters': {
17+
'detailed': {
18+
'format': '%(asctime)s - %(name)s - %(filename)s - %(levelname)s - %(message)s',
19+
},
20+
'brief': {
21+
'format': '%(levelname)s - %(message)s',
22+
},
23+
},
24+
'handlers': {
25+
'file': {
26+
'class': 'logging.handlers.RotatingFileHandler',
27+
'level': 'DEBUG',
28+
'formatter': 'detailed',
29+
'filename': 'logs/preprocessing.log',
30+
'mode': 'a',
31+
'encoding': 'utf-8',
32+
'maxBytes': 10485760,
33+
'backupCount': 5,
34+
},
35+
'console': {
36+
'class': 'logging.StreamHandler',
37+
'level': 'INFO',
38+
'formatter': 'brief',
39+
},
40+
},
41+
'loggers': {
42+
'preprocessing_logger': {
43+
'level': 'INFO',
44+
'handlers': ['file', 'console'],
45+
'propagate': False,
46+
},
47+
},
48+
'root': {
49+
'level': 'DEBUG',
50+
'handlers': ['file', 'console'],
51+
},
52+
}
53+
1454
# Load logging configuration
15-
current_dir = os.path.dirname(os.path.realpath(__file__))
16-
logging_config = os.path.join(current_dir, "logging_config.yaml")
17-
with open(logging_config, encoding='utf-8') as file:
18-
config = yaml.safe_load(file)
19-
logging.config.dictConfig(config)
55+
logging.config.dictConfig(logging_config)
2056

2157
# Central logger accessible throughout the application
2258
logger = logging.getLogger("preprocessing_logger")

0 commit comments

Comments
 (0)