Don't log /ping healthcheck requests

This commit is contained in:
cmdr2 2022-09-08 18:43:22 +05:30 committed by GitHub
parent dc9f6013e8
commit 6efbe62dca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,7 @@ OUTPUT_DIRNAME = "Stable Diffusion UI" # in the user's home folder
from fastapi import FastAPI, HTTPException
from starlette.responses import FileResponse
from pydantic import BaseModel
import logging
from sd_internal import Request, Response
@ -116,5 +117,12 @@ def read_modifiers():
def read_home_dir():
return {outpath}
# don't log /ping requests
class HealthCheckLogFilter(logging.Filter):
def filter(self, record: logging.LogRecord) -> bool:
return record.getMessage().find('/ping') == -1
logging.getLogger('uvicorn.access').addFilter(HealthCheckLogFilter())
# start the browser ui
import webbrowser; webbrowser.open('http://localhost:9000')