mirror of
https://github.com/tcsenpai/multi1.git
synced 2025-06-06 19:15:23 +00:00
27 lines
838 B
Python
27 lines
838 B
Python
import logging
|
|
import os
|
|
from datetime import datetime
|
|
|
|
def setup_logger():
|
|
# Create a logs directory if it doesn't exist
|
|
log_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'logs')
|
|
os.makedirs(log_dir, exist_ok=True)
|
|
|
|
# Create a unique log file name based on the current timestamp
|
|
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
log_file = os.path.join(log_dir, f"multi1_{timestamp}.log")
|
|
|
|
# Configure the logger
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
|
handlers=[
|
|
logging.FileHandler(log_file),
|
|
logging.StreamHandler() # This will also print logs to console
|
|
]
|
|
)
|
|
|
|
return logging.getLogger('multi1')
|
|
|
|
# Create a global logger instance
|
|
logger = setup_logger() |