File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 11import logging .config
2+ import re
3+ from logging import Filter , LogRecord
24from typing import Dict , Optional , Type , TypeVar
35
46from fastapi import FastAPI , HTTPException , Request
2729RequestType = TypeVar ("RequestType" , bound = FromRequestMixin )
2830
2931
32+ class PathFilter (Filter ):
33+ path : str
34+
35+ def __init__ (self , path : str ) -> None :
36+ super ().__init__ (name = "" )
37+ self .path = path
38+
39+ def filter (self , record : LogRecord ):
40+ return not re .search (f"(\\ s+){ self .path } (\\ s+)" , record .getMessage ())
41+
42+
3043class DIALApp (FastAPI ):
3144 chat_completion_impls : Dict [str , ChatCompletion ] = {}
3245
@@ -52,7 +65,9 @@ def __init__(
5265 HeaderPropagator (self , dial_url ).enable ()
5366
5467 if add_healthcheck :
55- self .add_api_route ("/health" , DIALApp ._healthcheck , methods = ["GET" ])
68+ path = "/health"
69+ self .add_api_route (path , DIALApp ._healthcheck , methods = ["GET" ])
70+ logging .getLogger ("uvicorn.access" ).addFilter (PathFilter (path ))
5671
5772 self .add_api_route (
5873 "/openai/deployments/{deployment_id}/chat/completions" ,
You can’t perform that action at this time.
0 commit comments