Coverage for orchestr_ant_ion / logging_config.py: 0%
14 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-19 08:36 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-19 08:36 +0000
1"""Logging configuration helpers for the project."""
3from __future__ import annotations
5import os
6import sys
7from pathlib import Path
9from loguru import logger
12CONSOLE_FORMAT = (
13 "<green>{time:HH:mm:ss}</green> | <level>{level: <8}</level> | "
14 "<cyan>{name}:{function}:{line}</cyan> | <level>{message}</level>"
15)
16FILE_FORMAT = (
17 "{time:YYYY-MM-DD HH:mm:ss.SSS} | {level: <8} | {process}:{thread} | "
18 "{name}:{function}:{line} | {message}"
19)
22def setup_logging(log_filename: str = "logs/catcam.log") -> None:
23 """Configure loguru logging for console and rotating file output."""
24 log_path = Path(log_filename)
25 log_path.parent.mkdir(parents=True, exist_ok=True)
27 log_level = os.getenv("KATAGLYPHIS_LOG_LEVEL", "INFO").upper()
28 logger.remove()
29 logger.add(
30 sink=sys.stdout,
31 format=CONSOLE_FORMAT,
32 level=log_level,
33 )
34 logger.add(
35 str(log_path),
36 rotation="1 MB",
37 retention=10,
38 compression="zip",
39 level=log_level,
40 format=FILE_FORMAT,
41 )