From 12688b9770a1dbffbddd4bc218d532e1330db8cf Mon Sep 17 00:00:00 2001 From: Lukas Date: Sat, 25 Oct 2025 17:54:18 +0200 Subject: [PATCH] better logging --- run_server.py | 16 +++++----------- src/infrastructure/logging/uvicorn_config.py | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/run_server.py b/run_server.py index 34f13df..39f173c 100644 --- a/run_server.py +++ b/run_server.py @@ -13,21 +13,15 @@ if __name__ == "__main__": log_config = get_uvicorn_log_config() # Run the application with logging. - # Exclude directories that should not trigger reloads to prevent - # infinite loops caused by log file writes. + # Only watch .py files in src/, explicitly exclude __pycache__. + # This prevents reload loops from .pyc compilation. uvicorn.run( "src.server.fastapi_app:app", host="127.0.0.1", port=8000, reload=True, - reload_excludes=[ - "logs/*", - "data/*", - "Temp/*", - "__pycache__/*", - "*.log", - "*.json", - "*.jsonl", - ], + reload_dirs=["src"], + reload_includes=["*.py"], + reload_excludes=["*/__pycache__/*", "*.pyc"], log_config=log_config, ) diff --git a/src/infrastructure/logging/uvicorn_config.py b/src/infrastructure/logging/uvicorn_config.py index 6a08551..e047abc 100644 --- a/src/infrastructure/logging/uvicorn_config.py +++ b/src/infrastructure/logging/uvicorn_config.py @@ -16,9 +16,17 @@ LOGGING_CONFIG = { "disable_existing_loggers": False, "formatters": { "default": { - "format": "%(levelprefix)s %(message)s", + "()": "uvicorn.logging.DefaultFormatter", + "fmt": "%(levelprefix)s %(message)s", "use_colors": None, }, + "access": { + "()": "uvicorn.logging.AccessFormatter", + "fmt": ( + '%(levelprefix)s %(client_addr)s - ' + '"%(request_line)s" %(status_code)s' + ), + }, "detailed": { "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s", "datefmt": "%Y-%m-%d %H:%M:%S", @@ -56,6 +64,11 @@ LOGGING_CONFIG = { "level": "INFO", "propagate": False, }, + "watchfiles.main": { + "handlers": ["console"], + "level": "WARNING", + "propagate": False, + }, "aniworld": { "handlers": ["console", "file"], "level": "INFO",