mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user