mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 08:21:26 +00:00
refactor(logging): migrate non-agent internal console calls to subsystem logger (#22964)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: b4a5b12422
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
committed by
GitHub
parent
4ef4aa3c10
commit
2f46308d5a
@@ -1,4 +1,5 @@
|
||||
import { RateLimitError } from "@buape/carbon";
|
||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||
import { formatErrorMessage } from "./errors.js";
|
||||
import { type RetryConfig, resolveRetryConfig, retryAsync } from "./retry.js";
|
||||
|
||||
@@ -19,6 +20,7 @@ export const TELEGRAM_RETRY_DEFAULTS = {
|
||||
};
|
||||
|
||||
const TELEGRAM_RETRY_RE = /429|timeout|connect|reset|closed|unavailable|temporarily/i;
|
||||
const log = createSubsystemLogger("retry-policy");
|
||||
|
||||
function getTelegramRetryAfterMs(err: unknown): number | undefined {
|
||||
if (!err || typeof err !== "object") {
|
||||
@@ -61,7 +63,7 @@ export function createDiscordRetryRunner(params: {
|
||||
? (info) => {
|
||||
const labelText = info.label ?? "request";
|
||||
const maxRetries = Math.max(1, info.maxAttempts - 1);
|
||||
console.warn(
|
||||
log.warn(
|
||||
`discord ${labelText} rate limited, retry ${info.attempt}/${maxRetries} in ${info.delayMs}ms`,
|
||||
);
|
||||
}
|
||||
@@ -92,7 +94,7 @@ export function createTelegramRetryRunner(params: {
|
||||
onRetry: params.verbose
|
||||
? (info) => {
|
||||
const maxRetries = Math.max(1, info.maxAttempts - 1);
|
||||
console.warn(
|
||||
log.warn(
|
||||
`telegram send retry ${info.attempt}/${maxRetries} for ${info.label ?? label ?? "request"} in ${info.delayMs}ms: ${formatErrorMessage(info.err)}`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { resolveSessionAgentId } from "../agents/agent-scope.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import type { SessionEntry, SessionMaintenanceWarning } from "../config/sessions.js";
|
||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||
import { isDeliverableMessageChannel, normalizeMessageChannel } from "../utils/message-channel.js";
|
||||
import { resolveSessionDeliveryTarget } from "./outbound/targets.js";
|
||||
import { enqueueSystemEvent } from "./system-events.js";
|
||||
@@ -13,6 +14,7 @@ type WarningParams = {
|
||||
};
|
||||
|
||||
const warnedContexts = new Map<string, string>();
|
||||
const log = createSubsystemLogger("session-maintenance-warning");
|
||||
|
||||
function shouldSendWarning(): boolean {
|
||||
return !process.env.VITEST && process.env.NODE_ENV !== "test";
|
||||
@@ -104,7 +106,7 @@ export async function deliverSessionMaintenanceWarning(params: WarningParams): P
|
||||
agentId: resolveSessionAgentId({ sessionKey: params.sessionKey, config: params.cfg }),
|
||||
});
|
||||
} catch (err) {
|
||||
console.warn(`Failed to deliver session maintenance warning: ${String(err)}`);
|
||||
log.warn(`Failed to deliver session maintenance warning: ${String(err)}`);
|
||||
enqueueSystemEvent(text, { sessionKey: params.sessionKey });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user