checkpoint

This commit is contained in:
Ace
2024-05-12 02:00:26 +02:00
parent 9346fcf750
commit 610f246c02
18 changed files with 225 additions and 180 deletions

35
inkycal/loggers.py Normal file
View File

@@ -0,0 +1,35 @@
"""Logging configuration for Inkycal."""
import logging
import os
from logging.handlers import RotatingFileHandler
from inkycal.settings import Settings
# On the console, set a logger to show only important logs
# (level ERROR or higher)
stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.ERROR)
settings = Settings()
if not os.path.exists(settings.LOG_PATH):
os.mkdir(settings.LOG_PATH)
# Save all logs to a file, which contains more detailed output
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s | %(name)s | %(levelname)s: %(message)s',
datefmt='%d-%m-%Y %H:%M:%S',
handlers=[
stream_handler, # add stream handler from above
RotatingFileHandler( # log to a file too
settings.INKYCAL_LOG_PATH, # file to log
maxBytes=2*1024*1024, # 2MB max filesize
backupCount=5 # create max 5 log files
)
]
)
# Show less logging for PIL module
logging.getLogger("PIL").setLevel(logging.WARNING)