favicon 204
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
import logging
|
import logging
|
||||||
class IgnoreHealth(logging.Filter):
|
|
||||||
def __init__(self, name: str = ""): super().__init__(name)
|
class IgnoreHealthAndFavicon(logging.Filter):
|
||||||
|
def __init__(self, name: str = ""):
|
||||||
|
super().__init__(name)
|
||||||
|
|
||||||
def filter(self, record: logging.LogRecord) -> bool:
|
def filter(self, record: logging.LogRecord) -> bool:
|
||||||
return "/health" not in record.getMessage()
|
msg = record.getMessage()
|
||||||
|
return all(p not in msg for p in ["/health", "/favicon.ico"])
|
||||||
|
@@ -6,5 +6,9 @@ import uvicorn
|
|||||||
app = FastAPI(title='IP Geo API')
|
app = FastAPI(title='IP Geo API')
|
||||||
app.include_router(router)
|
app.include_router(router)
|
||||||
|
|
||||||
|
@app.get("/favicon.ico")
|
||||||
|
async def favicon():
|
||||||
|
return Response(status_code=204)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
uvicorn.run('app.main:app', host=settings.host, port=settings.port, log_level=settings.log_level)
|
uvicorn.run('app.main:app', host=settings.host, port=settings.port, log_level=settings.log_level)
|
||||||
|
@@ -3,7 +3,7 @@ disable_existing_loggers: False
|
|||||||
|
|
||||||
filters:
|
filters:
|
||||||
ignore_health:
|
ignore_health:
|
||||||
"()": app.logging_filter.IgnoreHealth
|
"()": app.logging_filter.IgnoreHealthAndFavicon
|
||||||
|
|
||||||
formatters:
|
formatters:
|
||||||
default:
|
default:
|
||||||
|
Reference in New Issue
Block a user