mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 20:48: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
@@ -2,6 +2,7 @@ import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { MANIFEST_KEY } from "../compat/legacy-names.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||
import { isPathInsideWithRealpath } from "../security/scan-paths.js";
|
||||
import { CONFIG_DIR, resolveUserPath } from "../utils.js";
|
||||
import { resolveBundledHooksDir } from "./bundled-dir.js";
|
||||
@@ -23,6 +24,7 @@ import type {
|
||||
type HookPackageManifest = {
|
||||
name?: string;
|
||||
} & Partial<Record<typeof MANIFEST_KEY, { hooks?: string[] }>>;
|
||||
const log = createSubsystemLogger("hooks/workspace");
|
||||
|
||||
function filterHookEntries(
|
||||
entries: HookEntry[],
|
||||
@@ -95,7 +97,7 @@ function loadHookFromDir(params: {
|
||||
}
|
||||
|
||||
if (!handlerPath) {
|
||||
console.warn(`[hooks] Hook "${name}" has HOOK.md but no handler file in ${params.hookDir}`);
|
||||
log.warn(`Hook "${name}" has HOOK.md but no handler file in ${params.hookDir}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -109,7 +111,8 @@ function loadHookFromDir(params: {
|
||||
handlerPath,
|
||||
};
|
||||
} catch (err) {
|
||||
console.warn(`[hooks] Failed to load hook from ${params.hookDir}:`, err);
|
||||
const message = err instanceof Error ? (err.stack ?? err.message) : String(err);
|
||||
log.warn(`Failed to load hook from ${params.hookDir}: ${message}`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -145,8 +148,8 @@ function loadHooksFromDir(params: { dir: string; source: HookSource; pluginId?:
|
||||
for (const hookPath of packageHooks) {
|
||||
const resolvedHookDir = resolveContainedDir(hookDir, hookPath);
|
||||
if (!resolvedHookDir) {
|
||||
console.warn(
|
||||
`[hooks] Ignoring out-of-package hook path "${hookPath}" in ${hookDir} (must be within package directory)`,
|
||||
log.warn(
|
||||
`Ignoring out-of-package hook path "${hookPath}" in ${hookDir} (must be within package directory)`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user