improve logging

This commit is contained in:
Shroominic
2025-08-02 14:05:22 -03:00
parent 2a56998450
commit 658fc0c4f5
3 changed files with 13 additions and 24 deletions
+11 -11
View File
@@ -8,6 +8,7 @@ from pathlib import Path
from typing import Any
from pythonjsonlogger import jsonlogger
from rich.logging import RichHandler
class DailyRotatingFileHandler(logging.handlers.TimedRotatingFileHandler):
@@ -181,10 +182,6 @@ def setup_logging() -> None:
"format": "%(asctime)s %(name)s %(levelname)s %(message)s %(pathname)s %(lineno)d %(version)s",
"datefmt": "%Y-%m-%d %H:%M:%S",
},
"standard": {
"format": "%(asctime)s [%(levelname)s] %(name)s v%(version)s: %(message)s",
"datefmt": "%Y-%m-%d %H:%M:%S",
},
},
"filters": {
"version_filter": {"()": VersionFilter},
@@ -192,11 +189,13 @@ def setup_logging() -> None:
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"()": RichHandler,
"level": log_level,
"formatter": "standard",
"stream": "ext://sys.stdout",
"filters": ["version_filter", "security_filter"],
"show_time": False,
"show_path": False,
"rich_tracebacks": True,
"markup": True,
"filters": ["security_filter"],
},
"file": {
"()": DailyRotatingFileHandler,
@@ -252,11 +251,12 @@ def setup_logging() -> None:
"handlers": ["console"] if console_enabled else [],
"propagate": False,
},
"watchfiles": {
"level": "WARNING",
"handlers": ["console"] if console_enabled else [],
"uvicorn.error": {
"level": "INFO",
"handlers": ["console"],
"propagate": False,
},
"watchfiles.main": {"level": "WARNING", "handlers": [], "propagate": False},
},
"root": {
"level": log_level,
-11
View File
@@ -28,17 +28,11 @@ async def lifespan(_: FastAPI) -> AsyncGenerator[None, None]:
try:
await init_db()
logger.info("Database initialized successfully")
pricing_task = asyncio.create_task(update_sats_pricing())
refund_task = asyncio.create_task(check_for_refunds())
payout_task = asyncio.create_task(periodic_payout())
logger.info(
"Background tasks started successfully",
extra={"tasks": ["pricing", "refunds", "payouts"]},
)
yield
except Exception as e:
@@ -106,8 +100,3 @@ app.include_router(balance_router)
app.include_router(deprecated_wallet_router)
app.include_router(providers_router)
app.include_router(proxy_router)
logger.info(
"Application initialized successfully",
extra={"version": __version__, "routers_count": 5},
)
+2 -2
View File
@@ -117,11 +117,11 @@ async def send_to_lnurl(amount: int, unit: CurrencyUnit, lnurl: str) -> dict[str
async def check_for_refunds() -> None:
print("check_for_refunds, temp not implemented")
logger.warning("check_for_refunds, temporary not implemented")
async def periodic_payout() -> None:
print("periodic_payout, temp not implemented")
logger.warning("periodic_payout, temporary not implemented")
# class Proof: