Fixed up the current commands. Added a logger. Added a catch-all

This commit is contained in:
Dan
2024-05-04 16:36:42 -04:00
parent 07ce578edf
commit 4599f49e84
3 changed files with 68 additions and 13 deletions

17
dolly/logger.py Normal file
View File

@@ -0,0 +1,17 @@
import logging
from logging.handlers import RotatingFileHandler
# Configure basic logger
logging.basicConfig(level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
# Create a rotating file handler which logs even debug messages
log_file = 'dolly.log'
handler = RotatingFileHandler(log_file, maxBytes=100000, backupCount=3)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logger = logging.getLogger('Dolly')
logger.addHandler(handler)
logger.setLevel(logging.INFO)