feat(logging): Integrate log pruning and auto-whitelisting into app lifecycle

This commit is contained in:
2026-02-26 09:08:31 -05:00
parent 4e9c47f081
commit 8b7588323e
2 changed files with 31 additions and 3 deletions

View File

@@ -22,6 +22,8 @@ import numpy as np
import api_hooks
import mcp_client
from performance_monitor import PerformanceMonitor
from log_registry import LogRegistry
from log_pruner import LogPruner
from fastapi import FastAPI, Depends, HTTPException, Security
from fastapi.security.api_key import APIKeyHeader
@@ -265,8 +267,22 @@ class App:
label = self.project.get("project", {}).get("name", "")
session_logger.open_session(label=label)
self._prune_old_logs()
self._init_ai_and_hooks()
def _prune_old_logs(self):
"""Asynchronously prunes old insignificant logs on startup."""
def run_prune():
try:
registry = LogRegistry("logs/log_registry.toml")
pruner = LogPruner(registry, "logs")
pruner.prune()
except Exception as e:
print(f"Error during log pruning: {e}")
thread = threading.Thread(target=run_prune, daemon=True)
thread.start()
@property
def current_provider(self):
return self._current_provider