File size: 514 Bytes
cc8fad5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# api/logger.py
"""
Central logging configuration for Clare.
Set CLARE_LOG_LEVEL=DEBUG in .env to enable verbose logging.
Levels: DEBUG, INFO, WARNING, ERROR
"""
import logging
import os

CLARE_LOG_LEVEL = os.getenv("CLARE_LOG_LEVEL", "INFO").strip().upper()

logging.basicConfig(
    level=getattr(logging, CLARE_LOG_LEVEL, logging.INFO),
    format="%(asctime)s [%(levelname)s] %(name)s — %(message)s",
    datefmt="%H:%M:%S",
)

def get_logger(name: str) -> logging.Logger:
    return logging.getLogger(name)