Skip to content

Commit 6bb9e87

Browse files
FEAT: Integrate Logger for unified terminal and file output in Main Template main.py
1 parent b1cfaee commit 6bb9e87

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Main Template/main.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@
5050
import datetime # For getting the current date and time
5151
import os # For running a command in the terminal
5252
import platform # For getting the operating system name
53+
import sys # For system-specific parameters and functions
5354
from colorama import Style # For coloring the terminal
55+
from Logger import Logger # For logging output to both terminal and file
56+
from pathlib import Path # For handling file paths
5457

5558
# Macros:
5659
class BackgroundColors: # Colors for the terminal
@@ -65,6 +68,11 @@ class BackgroundColors: # Colors for the terminal
6568
# Execution Constants:
6669
VERBOSE = False # Set to True to output verbose messages
6770

71+
# Logger Setup:
72+
logger = Logger(f"./Logs/{Path(__file__).stem}.log", clean=True) # Create a Logger instance
73+
sys.stdout = logger # Redirect stdout to the logger
74+
sys.stderr = logger # Redirect stderr to the logger
75+
6876
# Sound Constants:
6977
SOUND_COMMANDS = {"Darwin": "afplay", "Linux": "aplay", "Windows": "start"} # The commands to play a sound for each operating system
7078
SOUND_FILE = "./.assets/Sounds/NotificationSound.wav" # The path to the sound file

0 commit comments

Comments
 (0)