Last active
January 9, 2025 01:17
-
-
Save janusson/8ee50fda855cef1efa9600f5ed5bdc1a to your computer and use it in GitHub Desktop.
Basic Logging Setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import os | |
# Ensure the logs directory exists | |
log_dir = './logs' | |
os.makedirs(log_dir, exist_ok=True) | |
# Configure logging | |
logging.basicConfig( | |
level=logging.INFO, | |
filename=os.path.join(log_dir, f'{__name__}.log'), | |
filemode='a', # Append to the log file | |
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' | |
) | |
logger = logging.getLogger(__name__) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment