better logging

This commit is contained in:
Lukas 2025-10-25 17:54:18 +02:00
parent eb4be2926b
commit 12688b9770
2 changed files with 19 additions and 12 deletions

View File

@ -13,21 +13,15 @@ if __name__ == "__main__":
log_config = get_uvicorn_log_config() log_config = get_uvicorn_log_config()
# Run the application with logging. # Run the application with logging.
# Exclude directories that should not trigger reloads to prevent # Only watch .py files in src/, explicitly exclude __pycache__.
# infinite loops caused by log file writes. # This prevents reload loops from .pyc compilation.
uvicorn.run( uvicorn.run(
"src.server.fastapi_app:app", "src.server.fastapi_app:app",
host="127.0.0.1", host="127.0.0.1",
port=8000, port=8000,
reload=True, reload=True,
reload_excludes=[ reload_dirs=["src"],
"logs/*", reload_includes=["*.py"],
"data/*", reload_excludes=["*/__pycache__/*", "*.pyc"],
"Temp/*",
"__pycache__/*",
"*.log",
"*.json",
"*.jsonl",
],
log_config=log_config, log_config=log_config,
) )

View File

@ -16,9 +16,17 @@ LOGGING_CONFIG = {
"disable_existing_loggers": False, "disable_existing_loggers": False,
"formatters": { "formatters": {
"default": { "default": {
"format": "%(levelprefix)s %(message)s", "()": "uvicorn.logging.DefaultFormatter",
"fmt": "%(levelprefix)s %(message)s",
"use_colors": None, "use_colors": None,
}, },
"access": {
"()": "uvicorn.logging.AccessFormatter",
"fmt": (
'%(levelprefix)s %(client_addr)s - '
'"%(request_line)s" %(status_code)s'
),
},
"detailed": { "detailed": {
"format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s", "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s",
"datefmt": "%Y-%m-%d %H:%M:%S", "datefmt": "%Y-%m-%d %H:%M:%S",
@ -56,6 +64,11 @@ LOGGING_CONFIG = {
"level": "INFO", "level": "INFO",
"propagate": False, "propagate": False,
}, },
"watchfiles.main": {
"handlers": ["console"],
"level": "WARNING",
"propagate": False,
},
"aniworld": { "aniworld": {
"handlers": ["console", "file"], "handlers": ["console", "file"],
"level": "INFO", "level": "INFO",