Remove noisy logging for mongo

This commit is contained in:
jetli 2025-01-22 00:28:26 -08:00
parent 9f5e0d1706
commit 10d87d4889

View File

@ -2,9 +2,10 @@ import logging
import sys
from loguru import logger
from common.config.log_settings import log_settings
from fastapi import FastAPI
def register(app=None):
def register(app: FastAPI):
level = log_settings.LOG_LEVEL
file_path = log_settings.LOG_PATH
retention = log_settings.LOG_RETENTION
@ -24,6 +25,7 @@ def register(app=None):
logger.add(sink=sys.stdout)
logger.add(sink=file_path, level=level, retention=retention, rotation=rotation)
# Disable noisy loggers
logger.disable("pika.adapters")
logger.disable("pika.connection")
logger.disable("pika.channel")
@ -32,6 +34,16 @@ def register(app=None):
logger.disable("pika.spec")
logger.disable("aiormq.connection")
logger.disable("urllib3.connectionpool")
# Disable noisy MongoDB debug logs
logging.getLogger("pymongo").setLevel(logging.WARNING)
logging.getLogger("mongodb_migrations").setLevel(logging.WARNING)
logging.getLogger("asyncio").setLevel(logging.WARNING)
logging.getLogger("motor").setLevel(logging.WARNING)
def boot(app: FastAPI):
pass
class InterceptHandler(logging.Handler):