|
|
""" |
|
|
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) |
|
|
] |
|
|
) |
|
|
|
|
|
|
|
|
logging.getLogger("uvicorn").setLevel(logging.INFO) |
|
|
logging.getLogger("fastapi").setLevel(logging.INFO) |
|
|
logging.getLogger("yolov5").setLevel(logging.WARNING) |
|
|
|
|
|
|
|
|
def get_logger(name: str) -> logging.Logger: |
|
|
""" |
|
|
Get a logger instance. |
|
|
|
|
|
Args: |
|
|
name: Logger name |
|
|
|
|
|
Returns: |
|
|
Logger instance |
|
|
""" |
|
|
return logging.getLogger(name) |
|
|
|