filter flaskwebgui log

This commit is contained in:
Sanster 2022-04-18 15:29:29 +08:00
parent a219da27f7
commit 71599e9c6d

View File

@ -48,15 +48,15 @@ if os.environ.get("CACHE_DIR"):
BUILD_DIR = os.environ.get("LAMA_CLEANER_BUILD_DIR", "app/build") BUILD_DIR = os.environ.get("LAMA_CLEANER_BUILD_DIR", "app/build")
class InterceptHandler(logging.Handler): class NoFlaskwebgui(logging.Filter):
def emit(self, record): def filter(self, record):
logger_opt = logger.opt(depth=6, exception=record.exc_info) return 'GET //flaskwebgui-keep-server-alive' not in record.getMessage()
logger_opt.log(record.levelno, record.getMessage())
logging.getLogger("werkzeug").addFilter(NoFlaskwebgui())
app = Flask(__name__, static_folder=os.path.join(BUILD_DIR, "static")) app = Flask(__name__, static_folder=os.path.join(BUILD_DIR, "static"))
app.config["JSON_AS_ASCII"] = False app.config["JSON_AS_ASCII"] = False
app.logger.addHandler(InterceptHandler())
CORS(app, expose_headers=["Content-Disposition"]) CORS(app, expose_headers=["Content-Disposition"])
model: ModelManager = None model: ModelManager = None