logging_config.py•1.08 kB
"""
Centralized logging configuration for TimeLooker.
"""
import logging
import os
def setup_logging(name: str = None, level: str = None) -> logging.Logger:
"""
Set up standardized logging configuration.
Args:
name: Logger name (defaults to calling module)
level: Log level (defaults to INFO, or LOG_LEVEL env var)
Returns:
Configured logger instance
"""
# Configure basic logging if not already done
if not logging.getLogger().handlers:
log_level = level or os.getenv('LOG_LEVEL', 'INFO').upper()
logging.basicConfig(
level=getattr(logging, log_level),
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
# Return logger for the specific module
return logging.getLogger(name or __name__)
def get_logger(name: str) -> logging.Logger:
"""
Get a logger instance with standard configuration.
Args:
name: Logger name (typically __name__)
Returns:
Logger instance
"""
return logging.getLogger(name)