Migrate to python logging module with env var control.

This commit is contained in:
Self Denial 2024-03-20 17:11:36 -06:00
parent d865b9fe59
commit e6dd0bfbe0
15 changed files with 174 additions and 82 deletions

View file

@ -1,10 +1,15 @@
import logging
from litellm.proxy.proxy_server import ProxyConfig, initialize
from litellm.proxy.proxy_server import app
from fastapi import FastAPI, Request, Depends, status
from fastapi.responses import JSONResponse
from utils.utils import get_http_authorization_cred, get_current_user
from config import ENV
from config import SRC_LOG_LEVELS, ENV
log = logging.getLogger(__name__)
log.setLevel(SRC_LOG_LEVELS["LITELLM"])
proxy_config = ProxyConfig()
@ -33,7 +38,7 @@ async def auth_middleware(request: Request, call_next):
if ENV != "dev":
try:
user = get_current_user(get_http_authorization_cred(auth_header))
print(user)
log.debug(f"user: {user}")
except Exception as e:
return JSONResponse(status_code=400, content={"detail": str(e)})