Skip to content

Instantly share code, notes, and snippets.

@janusson
Last active January 9, 2025 01:17
Show Gist options
  • Save janusson/8ee50fda855cef1efa9600f5ed5bdc1a to your computer and use it in GitHub Desktop.
Save janusson/8ee50fda855cef1efa9600f5ed5bdc1a to your computer and use it in GitHub Desktop.
Basic Logging Setup
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