fishapi / app /core /logging.py
kamau1's picture
Initial commit
bcc2f7b verified
raw
history blame contribute delete
963 Bytes
"""
Logging configuration for the FastAPI application.
"""
import logging
import sys
from typing import Dict, Any
def setup_logging(level: str = "INFO") -> None:
"""
Setup logging configuration.
Args:
level: Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
"""
logging.basicConfig(
level=getattr(logging, level.upper()),
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
handlers=[
logging.StreamHandler(sys.stdout)
]
)
# Set specific loggers
logging.getLogger("uvicorn").setLevel(logging.INFO)
logging.getLogger("fastapi").setLevel(logging.INFO)
logging.getLogger("yolov5").setLevel(logging.WARNING) # Reduce YOLOv5 verbosity
def get_logger(name: str) -> logging.Logger:
"""
Get a logger instance.
Args:
name: Logger name
Returns:
Logger instance
"""
return logging.getLogger(name)