|
4 | 4 |
|
5 | 5 | import os |
6 | 6 | import logging.config |
7 | | -import yaml |
8 | 7 |
|
9 | 8 | # Ensure log directory exists |
10 | 9 | LOG_DIR = "logs" |
11 | 10 | if not os.path.exists(LOG_DIR): |
12 | 11 | os.makedirs(LOG_DIR) |
13 | 12 |
|
| 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 | + |
14 | 54 | # 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) |
20 | 56 |
|
21 | 57 | # Central logger accessible throughout the application |
22 | 58 | logger = logging.getLogger("preprocessing_logger") |
0 commit comments