Verbose logging: show DEBUG on console with func name and line number

- Lower console handler from INFO to DEBUG so all log calls are visible
- Enrich format to include function name and line number for full context:
  TIMESTAMP [LEVEL   ] module.func:line — message

https://claude.ai/code/session_01KjaNo9RXevw6x1DjJD8mj6
This commit is contained in:
Claude
2026-03-24 21:45:45 +00:00
parent d81a3d3974
commit f021410622
+3 -3
View File
@@ -5,7 +5,7 @@ from logging.handlers import RotatingFileHandler
from pathlib import Path from pathlib import Path
LOG_PATH = Path(__file__).parent.parent / "data" / "mailrelay.log" LOG_PATH = Path(__file__).parent.parent / "data" / "mailrelay.log"
LOG_FORMAT = "%(asctime)s [%(levelname)s] %(name)s: %(message)s" LOG_FORMAT = "%(asctime)s [%(levelname)-8s] %(name)s.%(funcName)s:%(lineno)d %(message)s"
MAX_BYTES = 5 * 1024 * 1024 # 5 MB MAX_BYTES = 5 * 1024 * 1024 # 5 MB
BACKUP_COUNT = 3 BACKUP_COUNT = 3
@@ -27,9 +27,9 @@ def get_logger(name: str) -> logging.Logger:
file_handler.setLevel(logging.DEBUG) file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(logging.Formatter(LOG_FORMAT)) file_handler.setFormatter(logging.Formatter(LOG_FORMAT))
# Console handler (INFO and above) # Console handler (all levels)
console_handler = logging.StreamHandler() console_handler = logging.StreamHandler()
console_handler.setLevel(logging.INFO) console_handler.setLevel(logging.DEBUG)
console_handler.setFormatter(logging.Formatter(LOG_FORMAT)) console_handler.setFormatter(logging.Formatter(LOG_FORMAT))
logger.addHandler(file_handler) logger.addHandler(file_handler)