/** * @fileoverview Plugin-internal unified logger (Task #2961). * * User feedback: "用 logger.info 走日志系统,不污染 stdout/stderr". * * The plugin is intentionally zero-runtime-dep (no `@ai-setting/roy-agent-core`, * no `pino`/`winston`). To route diagnostic output through a unified logger * WITHOUT polluting stdout/stderr, we ship a small, self-contained logger * here that mirrors the host agent's `createLogger` semantics: * * - `info` / `warn` / `error` / `debug` methods on every logger instance. * - Quiet-by-default mode: when `quietMode === true` (the default), all * log calls go to a per-category log file under * `${XDG_DATA_HOME:-~/.local/share}/roy-agent/logs/roy-plugin-task-show-.log`, * and DO NOT touch `console.log` / `console.warn` / `console.error`. * - Console output is only enabled when an operator explicitly calls * `setQuietMode(false)`. The env var `TASK_SHOW_DEBUG=1` no longer * re-enables console output — it is intentionally ignored (was the * previous band-aid in Task #2953). * - The log file path is created on first write (mkdir -p). * - Writes are synchronous append (`appendFileSync`) so the log is * durable even when the process exits immediately (subprocess shutdown). * * Why a new file instead of inlining in `plugin.ts`? Tests pin the * `createPluginLogger` symbol (RED-3 / RED-4 / RED-5) and the chat * subprocess test imports it from `../src/logger.js`. Co-locating the * logger means `server.ts`, `collector.ts`, and `plugin.ts` all import * the same `createPluginLogger` — one sink, one set of gates. * * NOTE: this logger is intentionally minimal. If the host agent ever * exposes a `createPluginLogger` factory in `@ai-setting/roy-agent-core`, * this file can be replaced with a thin re-export. */ export declare function isQuietMode(): boolean; export declare function setQuietMode(enabled: boolean): void; export interface PluginLogger { /** Log to file unconditionally. Console only when un-quiet. */ info(message: string, data?: unknown): void; warn(message: string, data?: unknown): void; error(message: string, data?: unknown): void; debug(message: string, data?: unknown): void; /** * Whether this logger currently routes to the console. True when * quiet mode is off AND the env says console output is allowed. * Tests use this to assert the default behaviour without spying on * `console.*` directly. */ readonly consoleEnabled: boolean; } /** * Create (or fetch from cache) a plugin logger under the given category * prefix. The prefix appears in the log file name and in each formatted * line so operators can grep for it. * * @param prefix A short identifier for the subsystem * (e.g. `"plugin"`, `"server"`, `"collector"`). */ export declare function createPluginLogger(prefix: string): PluginLogger; //# sourceMappingURL=logger.d.ts.map