From 0520aeb244770df8b4d0d033e40e90d9afce76ae Mon Sep 17 00:00:00 2001 From: Gustavo Madeira Santana Date: Wed, 22 Apr 2026 20:42:52 -0400 Subject: [PATCH] fix: restore Matrix quiet SDK logging --- CHANGELOG.md | 2 + .../matrix/src/matrix/client/logging.test.ts | 30 +++++++++++ .../matrix/src/matrix/client/logging.ts | 50 +++++++++++++++++-- 3 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 extensions/matrix/src/matrix/client/logging.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index f842f8cd405..2fabff70079 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -218,6 +218,8 @@ Docs: https://docs.openclaw.ai - Codex harness/hooks: fire `llm_input`, `llm_output`, and `agent_end` for native Codex app-server turns so lifecycle hooks stop drifting from Pi. Thanks @vincentkoc. - QA/Telegram: record per-scenario reply RTT in the live Telegram QA report and summary, starting with the canary response. (#70550) Thanks @obviyus. - Status: add an explicit `Runner:` field to `/status` so sessions now report whether they are running on embedded Pi, a CLI-backed provider, or an ACP harness agent/backend such as `codex (acp/acpx)` or `gemini (acp/acpx)`. (#70595) +- Gateway/diagnostics: enable payload-free stability recording by default and add a support-ready diagnostics export with sanitized logs, status, health, config, and stability snapshots for bug reports. (#70324) Thanks @gumadeiras. +- Matrix: require full cross-signing identity trust for self-device verification and add `openclaw matrix verify self` so operators can establish that trust from the CLI. (#70401) Thanks @gumadeiras. ### Fixes diff --git a/extensions/matrix/src/matrix/client/logging.test.ts b/extensions/matrix/src/matrix/client/logging.test.ts new file mode 100644 index 00000000000..7066c2f9cfc --- /dev/null +++ b/extensions/matrix/src/matrix/client/logging.test.ts @@ -0,0 +1,30 @@ +import { logger as matrixJsSdkLogger } from "matrix-js-sdk/lib/logger.js"; +import { afterEach, describe, expect, it, vi } from "vitest"; +import { LogService } from "../sdk/logger.js"; +import { + createMatrixJsSdkClientLogger, + ensureMatrixSdkLoggingConfigured, + setMatrixSdkConsoleLogging, + setMatrixSdkLogMode, +} from "./logging.js"; + +describe("Matrix SDK logging", () => { + afterEach(() => { + setMatrixSdkLogMode("default"); + setMatrixSdkConsoleLogging(false); + vi.restoreAllMocks(); + }); + + it("suppresses Matrix SDK client logs in quiet mode", () => { + setMatrixSdkConsoleLogging(true); + setMatrixSdkLogMode("quiet"); + ensureMatrixSdkLoggingConfigured(); + const info = vi.spyOn(console, "info").mockImplementation(() => {}); + + createMatrixJsSdkClientLogger("MatrixClient").info("should be quiet"); + matrixJsSdkLogger.info("global logger should be quiet"); + LogService.info("MatrixClient", "should also be quiet"); + + expect(info).not.toHaveBeenCalled(); + }); +}); diff --git a/extensions/matrix/src/matrix/client/logging.ts b/extensions/matrix/src/matrix/client/logging.ts index f75ce101a62..22007fbc4ed 100644 --- a/extensions/matrix/src/matrix/client/logging.ts +++ b/extensions/matrix/src/matrix/client/logging.ts @@ -2,6 +2,7 @@ import { logger as matrixJsSdkLogger } from "matrix-js-sdk/lib/logger.js"; import { ConsoleLogger, LogService, setMatrixConsoleLogging } from "../sdk/logger.js"; let matrixSdkLoggingConfigured = false; +let matrixSdkLogMode: "default" | "quiet" = "default"; const matrixSdkBaseLogger = new ConsoleLogger(); type MatrixJsSdkLogger = { @@ -32,7 +33,7 @@ export function ensureMatrixSdkLoggingConfigured(): void { } export function setMatrixSdkLogMode(mode: "default" | "quiet"): void { - void mode; + matrixSdkLogMode = mode; if (!matrixSdkLoggingConfigured) { return; } @@ -47,13 +48,42 @@ export function createMatrixJsSdkClientLogger(prefix = "matrix"): MatrixJsSdkLog return createMatrixJsSdkLoggerInstance(prefix); } +function shouldSuppressMatrixHttpNotFound(module: string, messageOrObject: unknown[]): boolean { + if (!module.includes("MatrixHttpClient")) { + return false; + } + return messageOrObject.some((entry) => { + if (!entry || typeof entry !== "object") { + return false; + } + return (entry as { errcode?: string }).errcode === "M_NOT_FOUND"; + }); +} + function applyMatrixSdkLogger(): void { + if (matrixSdkLogMode === "quiet") { + LogService.setLogger({ + trace: () => {}, + debug: () => {}, + info: () => {}, + warn: () => {}, + error: () => {}, + }); + applyMatrixJsSdkLogger(); + return; + } + LogService.setLogger({ trace: (module, ...messageOrObject) => matrixSdkBaseLogger.trace(module, ...messageOrObject), debug: (module, ...messageOrObject) => matrixSdkBaseLogger.debug(module, ...messageOrObject), info: (module, ...messageOrObject) => matrixSdkBaseLogger.info(module, ...messageOrObject), warn: (module, ...messageOrObject) => matrixSdkBaseLogger.warn(module, ...messageOrObject), - error: (module, ...messageOrObject) => matrixSdkBaseLogger.error(module, ...messageOrObject), + error: (module, ...messageOrObject) => { + if (shouldSuppressMatrixHttpNotFound(module, messageOrObject)) { + return; + } + matrixSdkBaseLogger.error(module, ...messageOrObject); + }, }); applyMatrixJsSdkLogger(); } @@ -78,6 +108,12 @@ function applyMatrixJsSdkLogger(): void { const method = normalizeMatrixJsSdkLogMethod(methodName); const module = formatMatrixJsSdkLoggerName(loggerName); return (...messageOrObject) => { + if (matrixSdkLogMode === "quiet") { + return; + } + if (method === "error" && shouldSuppressMatrixHttpNotFound(module, messageOrObject)) { + return; + } (matrixSdkBaseLogger[method] as (module: string, ...args: unknown[]) => void)( module, ...messageOrObject, @@ -90,6 +126,9 @@ function applyMatrixJsSdkLogger(): void { function createMatrixJsSdkLoggerInstance(prefix: string): MatrixJsSdkLogger { const log = (method: keyof ConsoleLogger, ...messageOrObject: unknown[]): void => { + if (matrixSdkLogMode === "quiet") { + return; + } (matrixSdkBaseLogger[method] as (module: string, ...args: unknown[]) => void)( prefix, ...messageOrObject, @@ -101,7 +140,12 @@ function createMatrixJsSdkLoggerInstance(prefix: string): MatrixJsSdkLogger { debug: (...messageOrObject) => log("debug", ...messageOrObject), info: (...messageOrObject) => log("info", ...messageOrObject), warn: (...messageOrObject) => log("warn", ...messageOrObject), - error: (...messageOrObject) => log("error", ...messageOrObject), + error: (...messageOrObject) => { + if (shouldSuppressMatrixHttpNotFound(prefix, messageOrObject)) { + return; + } + log("error", ...messageOrObject); + }, getChild: (namespace: string) => { const nextNamespace = namespace.trim(); return createMatrixJsSdkLoggerInstance(nextNamespace ? `${prefix}.${nextNamespace}` : prefix);