/** * Where logging goes, and whether it happens at all. * * The bug this exists for (NEX-3): `Logger` built four Winston File transports at * hard-coded RELATIVE paths, with no console transport and no injectable destination. * Winston's File transport mkdirs in its own constructor, so merely constructing a * Logger created `./logs/` — in whatever directory the process happened to start in. * For a published library that is the consumer's project directory; for the MCP server * it is whatever cwd its client chose. There was no way to turn it off. * * Configuration is process-global rather than constructor-injected because there are * ~43 field initializers of the form `private _logger = new Logger("FlowManager")`, * none of which receive arguments. Threading options through them would mean changing * every manager constructor. The consuming application configures once at boot; the * library reads its own environment so that a Logger used BEFORE that call still * behaves — which makes boot order an optimization rather than a correctness * requirement, and is what lets this work under Jest. */ import * as winston from "winston"; export interface LogOptions { /** Write log files. Off by default. */ file?: boolean; /** Directory for log files. Implies `file` when set. */ dir?: string; /** Threshold for what is recorded at all. */ level?: string; /** Emit to stderr. On by default — stdout is reserved for `--json` and JSON-RPC. */ console?: boolean; /** Threshold for stderr specifically. Defaults to `warn`. */ consoleLevel?: string; /** Rotate after this many bytes. */ maxSizeBytes?: number; /** Keep this many rotated files. */ maxFiles?: number; } export interface ResolvedLogConfig { readonly file: boolean; readonly dir: string; readonly level: string; readonly console: boolean; readonly consoleLevel: string; readonly maxSizeBytes: number; readonly maxFiles: number; } /** * Per-user state directory for logs. * * XDG_STATE_HOME is honoured on every platform, not just Linux. That is deliberate: it * makes the whole thing testable with one environment variable and no mocking, and it * matches how sn-credstore resolves its own state. */ export declare function defaultLogDir(): string; /** * The one winston logger for the process. * * Shared rather than per-`Logger` because rotation requires it: each File transport * tracks its own size and rotates independently, so N transports on one path interleave * renames and lose lines. It also fixes an fd leak — `ServiceNowRequest` is constructed * per HTTP call, and each one used to open four more append streams that were never * closed. That is where the 120 MB came from. */ export declare function getRootLogger(): winston.Logger; /** Bumped whenever configuration changes, so live `Logger` facades pick up the new root. */ export declare function logEpoch(): number; /** * Sets logging options for the process. Call once, early, from the application that * owns the entry point — not from a library. * * Unset fields keep whatever the environment or the defaults provide, so a consumer can * set only what it knows about. */ export declare function configureLogging(options?: LogOptions): void; export declare function getLogConfig(): ResolvedLogConfig; /** * Waits for buffered records to reach disk. * * Winston's File transport buffers, and `process.exit()` drops whatever is pending. A * library cannot register `process.on('exit')` for this because that handler cannot be * async, so the application calls this before exiting. */ export declare function flushLogs(): Promise; /** Drops all configuration and the built logger. Test seam. */ export declare function resetLoggingForTests(): void;