-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.py
39 lines (26 loc) · 998 Bytes
/
log.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""Logging configuration for the application."""
import logging
from .const import DT_STYLE_FOLDER, DT_STYLES, LOG_FOLDER
# Configure logging
LOG_FILE = LOG_FOLDER / "pano.log"
LOG_FORMAT = "%(asctime)s - %(name)-20s - %(levelname)-8s - %(message)s"
logging.basicConfig(
filename=LOG_FILE,
level=logging.INFO,
format=LOG_FORMAT,
datefmt="%Y-%m-%d %H:%M:%S",
)
def get_logger(name: str) -> logging.Logger:
"""Return a configured logger for a given module name."""
return logging.getLogger(name)
class LogMixin:
"""A mixin class to provide logging functionality."""
def __init__(self):
"""Initialize the logger."""
self.logger = get_logger(self.__class__.__name__)
self.logger.debug(f"Initializing {self.__class__.__name__}")
return
logger = get_logger(__name__)
logger.info(f"Logging to: {LOG_FILE}")
logger.info(f"Darktable style folder set to: {DT_STYLE_FOLDER}")
logger.info(f"Darktable styles available: {DT_STYLES}")