Skip to content

Commit a9232ef

Browse files
author
钟远
committed
fix: suppress plugin registration logs in CLI mode (#380)
In CLI mode (OPENCLAW_CLI=1), registration and lifecycle logs are downgraded from info to debug to avoid flooding stderr with ~11 lines of noise before command output. Affected logs: - smart extraction enabled - plugin registered (db, model, smartExtraction) - diagnostic build tag loaded - session-strategy: using none - session-memory: typed before_reset hook registered Gateway runtime behavior is unchanged (logs remain at info level).
1 parent 8bbca98 commit a9232ef

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

index.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ import { pathToFileURL } from "node:url";
1313
import { createRequire } from "node:module";
1414
import { spawn } from "node:child_process";
1515

16+
// Detect CLI mode: when running as a CLI subcommand (e.g. `openclaw memory-pro stats`),
17+
// OpenClaw sets OPENCLAW_CLI=1 in the process environment. Registration and
18+
// lifecycle logs are noisy in CLI context (printed to stderr before command output),
19+
// so we downgrade them to debug level when running in CLI mode.
20+
const isCliMode = () => process.env.OPENCLAW_CLI === "1";
21+
1622
// Import core components
1723
import { MemoryStore, validateStoragePath } from "./src/store.js";
1824
import { createEmbedder, getVectorDimensions } from "./src/embedder.js";
@@ -1737,7 +1743,7 @@ const memoryLanceDBProPlugin = {
17371743
noiseBank,
17381744
});
17391745

1740-
api.logger.info(
1746+
(isCliMode() ? api.logger.debug : api.logger.info)(
17411747
"memory-lancedb-pro: smart extraction enabled (LLM model: "
17421748
+ llmModel
17431749
+ ", timeoutMs: "
@@ -1981,10 +1987,11 @@ const memoryLanceDBProPlugin = {
19811987
const autoCapturePendingIngressTexts = new Map<string, string[]>();
19821988
const autoCaptureRecentTexts = new Map<string, string[]>();
19831989

1984-
api.logger.info(
1990+
const logReg = isCliMode() ? api.logger.debug : api.logger.info;
1991+
logReg(
19851992
`memory-lancedb-pro@${pluginVersion}: plugin registered (db: ${resolvedDbPath}, model: ${config.embedding.model || "text-embedding-3-small"}, smartExtraction: ${smartExtractor ? 'ON' : 'OFF'})`
19861993
);
1987-
api.logger.info(`memory-lancedb-pro: diagnostic build tag loaded (${DIAG_BUILD_TAG})`);
1994+
logReg(`memory-lancedb-pro: diagnostic build tag loaded (${DIAG_BUILD_TAG})`);
19881995

19891996
api.on("message_received", (event: any, ctx: any) => {
19901997
const conversationKey = buildAutoCaptureConversationKeyFromIngress(
@@ -3530,10 +3537,10 @@ const memoryLanceDBProPlugin = {
35303537
}
35313538
});
35323539

3533-
api.logger.info("session-memory: typed before_reset hook registered for /new session summaries");
3540+
(isCliMode() ? api.logger.debug : api.logger.info)("session-memory: typed before_reset hook registered for /new session summaries");
35343541
}
35353542
if (config.sessionStrategy === "none") {
3536-
api.logger.info("session-strategy: using none (plugin memory-reflection hooks disabled)");
3543+
(isCliMode() ? api.logger.debug : api.logger.info)("session-strategy: using none (plugin memory-reflection hooks disabled)");
35373544
}
35383545

35393546
// ========================================================================

0 commit comments

Comments
 (0)