import { Statistics } from "../statistics/statistics.js"; export type LogLevelName = "debug" | "info" | "warning" | "error"; /** * Numeric log threshold, ordered so that a message is emitted to the console * sink when its level is >= the current threshold. OFF silences everything. * Buffered entries (for displayLogs/proxies) are collected regardless of the * threshold — the threshold only controls what echoes to the console as it * happens. */ export declare enum LogLevel { DEBUG = 0, INFO = 1, WARNING = 2, ERROR = 3, OFF = 4 } export interface LogEntry { level: LogLevelName; message: string; count: number; expressIDs: Set; } export interface LoggingProxy { log(entry: LogEntry): void; } /** * Where echoed log lines go. The default writes through the matching console * method; the CLI swaps in a sink that writes everything to stderr so stdout * stays clean for data output. */ export type LogSink = (level: LogLevelName, message: string) => void; /** * Logger class which supports logging statistics, as well as proxy logging interfaces * for extended logging. * * Entries are deduplicated (repeat messages increment a count and accumulate * express IDs) and buffered for displayLogs()/proxies. Additionally, the * first occurrence of each distinct entry at or above the current threshold * is echoed to the console sink immediately, so warnings/errors are visible * live without waiting for a displayLogs() dump. */ export default class Logger { private static logs; private static proxies; private static statistics; private static threshold; private static sink; /** * Detects environment and initializes wasm callbacks */ static initializeWasmCallbacks(): void; /** * Set the console-echo threshold. Embedders (e.g. Share) call this to * quiet or expand conway's console output; the CLI maps -q/-v/-vv here. * * @param level - new threshold */ static setLogLevel(level: LogLevel): void; /** * * @return {LogLevel} the current console-echo threshold */ static getLogLevel(): LogLevel; /** * Is a given level at or above the current threshold? * * @param level - level to test * @return {boolean} true when messages at this level echo to the console */ static isLevelEnabled(level: LogLevel): boolean; /** * Replace the console sink (e.g. the CLI routes all echoes to stderr so * stdout stays parseable). Pass undefined to restore the default. * * @param sink - replacement sink or undefined */ static setSink(sink?: LogSink): void; /** * * @param message - log message * @param level - log level * @return {number} log index */ private static findLogIndex; /** * * @param level - log level * @param message - log message */ private static log; /** * Compresses similar logs to a single line */ static compressLogs(): void; /** * * @param proxy - a log proxy */ static addProxy(proxy: LoggingProxy): void; /** * Remove a previously added proxy (no-op if absent). * * @param proxy - the proxy to remove */ static removeProxy(proxy: LoggingProxy): void; /** * * @param message - log message */ static debug(message: string): void; /** * * @param message - log message */ static info(message: string): void; /** * * @param modelID * @return {Statistics | undefined} */ static getStatistics(modelID: number): Statistics | undefined; /** * Create the statistics for a model ID. * * @param modelID The model ID to create statistics for * * @return {Statistics} The created statistics object. */ static createStatistics(modelID: number): Statistics; /** * * @param modelID */ static printStatistics(modelID: number): void; /** * Compresses the logs if they haven't been compressed, * then returns a list of just the errors. * * @return {LogEntry[]} The errors. */ static getErrors(): LogEntry[]; /** * * @param message - log message */ static warning(message: string): void; /** * * @param message - log message */ static error(message: string): void; /** * * @return {LogEntry[]} - list of logs */ static getLogs(): LogEntry[]; /** * Display the deduplicated log buffer in a table. * * Gated behind the DEBUG threshold by default — a clean load should leave * a quiet console (issue #301); pass force for explicit dumps (CLI -v). * * @param force - dump regardless of the current threshold */ static displayLogs(force?: boolean): void; /** * clear logs */ static clearLogs(): void; } //# sourceMappingURL=logger.d.ts.map