fix: gate diagnostic logs behind verbose

This commit is contained in:
Peter Steinberger
2026-01-24 05:06:33 +00:00
parent 5662a9cdfc
commit 886752217d
2 changed files with 11 additions and 11 deletions

View File

@@ -43,7 +43,7 @@ export function abortEmbeddedPiRun(sessionId: string): boolean {
diag.debug(`abort failed: sessionId=${sessionId} reason=no_active_run`);
return false;
}
diag.info(`aborting run: sessionId=${sessionId}`);
diag.debug(`aborting run: sessionId=${sessionId}`);
handle.abort();
return true;
}
@@ -110,7 +110,7 @@ export function setActiveEmbeddedRun(sessionId: string, handle: EmbeddedPiQueueH
reason: wasActive ? "run_replaced" : "run_started",
});
if (!sessionId.startsWith("probe-")) {
diag.info(`run registered: sessionId=${sessionId} totalActive=${ACTIVE_EMBEDDED_RUNS.size}`);
diag.debug(`run registered: sessionId=${sessionId} totalActive=${ACTIVE_EMBEDDED_RUNS.size}`);
}
}
@@ -119,7 +119,7 @@ export function clearActiveEmbeddedRun(sessionId: string, handle: EmbeddedPiQueu
ACTIVE_EMBEDDED_RUNS.delete(sessionId);
logSessionStateChange({ sessionId, state: "idle", reason: "run_completed" });
if (!sessionId.startsWith("probe-")) {
diag.info(`run cleared: sessionId=${sessionId} totalActive=${ACTIVE_EMBEDDED_RUNS.size}`);
diag.debug(`run cleared: sessionId=${sessionId} totalActive=${ACTIVE_EMBEDDED_RUNS.size}`);
}
notifyEmbeddedRunEnded(sessionId);
} else {

View File

@@ -63,7 +63,7 @@ export function logWebhookReceived(params: {
}) {
webhookStats.received += 1;
webhookStats.lastReceived = Date.now();
diag.info(
diag.debug(
`webhook received: channel=${params.channel} type=${params.updateType ?? "unknown"} chatId=${
params.chatId ?? "unknown"
} total=${webhookStats.received}`,
@@ -84,7 +84,7 @@ export function logWebhookProcessed(params: {
durationMs?: number;
}) {
webhookStats.processed += 1;
diag.info(
diag.debug(
`webhook processed: channel=${params.channel} type=${
params.updateType ?? "unknown"
} chatId=${params.chatId ?? "unknown"} duration=${params.durationMs ?? 0}ms processed=${
@@ -132,7 +132,7 @@ export function logMessageQueued(params: {
const state = getSessionState(params);
state.queueDepth += 1;
state.lastActivity = Date.now();
diag.info(
diag.debug(
`message queued: sessionId=${state.sessionId ?? "unknown"} sessionKey=${
state.sessionKey ?? "unknown"
} source=${params.source} queueDepth=${state.queueDepth} sessionState=${state.state}`,
@@ -173,7 +173,7 @@ export function logMessageProcessed(params: {
} else if (params.outcome === "skipped") {
diag.debug(payload);
} else {
diag.info(payload);
diag.debug(payload);
}
emitDiagnosticEvent({
type: "message.processed",
@@ -203,7 +203,7 @@ export function logSessionStateChange(
state.lastActivity = Date.now();
if (params.state === "idle") state.queueDepth = Math.max(0, state.queueDepth - 1);
if (!isProbeSession) {
diag.info(
diag.debug(
`session state: sessionId=${state.sessionId ?? "unknown"} sessionKey=${
state.sessionKey ?? "unknown"
} prev=${prevState} new=${params.state} reason="${params.reason ?? ""}" queueDepth=${
@@ -263,7 +263,7 @@ export function logLaneDequeue(lane: string, waitMs: number, queueSize: number)
}
export function logRunAttempt(params: SessionRef & { runId: string; attempt: number }) {
diag.info(
diag.debug(
`run attempt: sessionId=${params.sessionId ?? "unknown"} sessionKey=${
params.sessionKey ?? "unknown"
} runId=${params.runId} attempt=${params.attempt}`,
@@ -285,7 +285,7 @@ export function logActiveRuns() {
([id, s]) =>
`${id}(q=${s.queueDepth},age=${Math.round((Date.now() - s.lastActivity) / 1000)}s)`,
);
diag.info(`active runs: count=${activeSessions.length} sessions=[${activeSessions.join(", ")}]`);
diag.debug(`active runs: count=${activeSessions.length} sessions=[${activeSessions.join(", ")}]`);
markActivity();
}
@@ -314,7 +314,7 @@ export function startDiagnosticHeartbeat() {
if (!hasActivity) return;
if (now - lastActivityAt > 120_000 && activeCount === 0 && waitingCount === 0) return;
diag.info(
diag.debug(
`heartbeat: webhooks=${webhookStats.received}/${webhookStats.processed}/${webhookStats.errors} active=${activeCount} waiting=${waitingCount} queued=${totalQueued}`,
);
emitDiagnosticEvent({