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:
Gustavo Madeira Santana
2026-02-21 17:44:00 -05:00
committed by GitHub
parent 4ef4aa3c10
commit 2f46308d5a
14 changed files with 102 additions and 29 deletions

View File

@@ -8,6 +8,7 @@
import type { WorkspaceBootstrapFile } from "../agents/workspace.js";
import type { CliDeps } from "../cli/deps.js";
import type { OpenClawConfig } from "../config/config.js";
import { createSubsystemLogger } from "../logging/subsystem.js";
export type InternalHookEventType = "command" | "session" | "agent" | "gateway" | "message";
@@ -111,6 +112,7 @@ export type InternalHookHandler = (event: InternalHookEvent) => Promise<void> |
/** Registry of hook handlers by event key */
const handlers = new Map<string, InternalHookHandler[]>();
const log = createSubsystemLogger("internal-hooks");
/**
* Register a hook handler for a specific event type or event:action combination
@@ -201,10 +203,8 @@ export async function triggerInternalHook(event: InternalHookEvent): Promise<voi
try {
await handler(event);
} catch (err) {
console.error(
`Hook error [${event.type}:${event.action}]:`,
err instanceof Error ? err.message : String(err),
);
const message = err instanceof Error ? err.message : String(err);
log.error(`Hook error [${event.type}:${event.action}]: ${message}`);
}
}
}