refactor(log): unify request lifecycle logging with session-colored tags

Collapse scattered per-request console lines (request/routing/auth/pending/
usage/stream-usage/stream) into 3 correlated lines: request, transform,
done. Add stable per-session color tag so concurrent request lines are
easy to follow, surface thinking intent, always-on full error logging
for debug, re-enable warn level, and uppercase keyword labels. Also fix
usage overview cards wrapping (5 cards -> grid-cols-5).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
decolua
2026-07-10 18:01:20 +07:00
co-authored by Cursor
parent b61c50cbb7
commit a625ea9fd8
11 changed files with 176 additions and 69 deletions
+7
View File
@@ -4,6 +4,9 @@
import { FORMATS } from "../translator/formats.js";
// Legacy per-chunk usage console line; off by default (superseded by "📊 done")
const DEBUG_USAGE = process.env.LOG_USAGE_VERBOSE === "1";
// ANSI color codes
export const COLORS = {
reset: "\x1b[0m",
@@ -401,6 +404,10 @@ export function estimateUsage(body, contentLength, targetFormat = FORMATS.OPENAI
export function logUsage(provider, usage, model = null, connectionId = null, apiKey = null) {
if (!usage || typeof usage !== "object") return;
// Console output moved to the unified "📊 done" line (streamingHandler). Kept as
// a no-op hook so callers stay unchanged; usage persistence happens via saveUsageStats.
if (!DEBUG_USAGE) return;
const p = provider?.toUpperCase() || "UNKNOWN";
// Support both formats: