Skip to content

Commit 4b7d9a2

Browse files
chore: Refactor logger directory creation code
1 parent 8713843 commit 4b7d9a2

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/logger.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
import os
44

55
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
6+
LOG_DIR = os.path.join(ROOT_DIR, 'logs')
67
# Create a logs directory if it doesn't exist
7-
os.makedirs(os.path.join(ROOT_DIR, 'logs'), exist_ok=True)
8+
os.makedirs(LOG_DIR, exist_ok=True)
89

910
# Log Formatter with datetime, log level, and message
1011
formatter = logging.Formatter(
@@ -14,7 +15,7 @@
1415

1516
# File handler for logging to a file
1617
file_handler = RotatingFileHandler(
17-
'logs/app_debug.log',
18+
os.path.join(LOG_DIR, 'app_debug.log'),
1819
maxBytes=10 * 1024 * 1024, # 10 MB per log file
1920
backupCount=5 # Keep up to 5 old log files
2021
)

0 commit comments

Comments
 (0)