Fix usage logging dedupe and reduce stats churn

- batch console log buffer events and support batched SSE log messages
- debounce usage stats update/pending events to reduce UI/runtime churn
- avoid awaiting request-success bookkeeping before returning provider responses
- deduplicate identical usage writes in usageHistory/daily aggregates
- reduce default logger verbosity from DEBUG to INFO (overridable via LOG_LEVEL)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Mink Nguyen
2026-06-26 10:22:20 +07:00
committed by decolua
co-authored by Cursor
parent ec096d2add
commit 0d21668917
7 changed files with 107 additions and 10 deletions
+1 -2
View File
@@ -7,7 +7,7 @@ const LOG_LEVELS = {
ERROR: 3
};
const LEVEL = LOG_LEVELS.DEBUG;
const LEVEL = LOG_LEVELS[process.env.LOG_LEVEL?.toUpperCase?.()] ?? LOG_LEVELS.INFO;
function formatTime() {
return new Date().toLocaleTimeString("en-US", { hour12: false });
@@ -72,4 +72,3 @@ export function maskKey(key) {
if (!key || key.length < 8) return "***";
return `${key.slice(0, 4)}...${key.slice(-4)}`;
}