/** * Log level hierarchy from least to most verbose. * - `'off'`: No logging * - `'error'`: Only errors * - `'warn'`: Errors and warnings * - `'info'`: Errors, warnings, and info (default) * - `'debug'`: All messages including debug */ export type LogLevel = 'off' | 'error' | 'warn' | 'info' | 'debug'; /** * Console interface subset used by `Logger` for output. * Allows custom console implementations for testing. */ export type LogConsole = Pick; /** * Converts a log level to its numeric value for comparison. * Higher numbers indicate more verbose logging. * @returns numeric value (0-4) */ export declare const log_level_to_number: (level: LogLevel) => number; /** * Parses and validates a log level string. * @returns the validated log level, or `undefined` if `value` is `undefined` * @throws Error if `value` is provided but invalid */ export declare const log_level_parse: (value: string | undefined) => LogLevel | undefined; /** * Simple, flexible logger with support for child loggers and automatic context. * * Features: * - Instance-based configuration (no global state) * - Child loggers with automatic label concatenation * - Parent chain inheritance for level, console, and colors * - Respects NO_COLOR environment variable * * @example * ```ts * // Basic logger * const log = new Logger('app'); * log.info('starting'); // [app] ➤ starting * * // Child logger * const db_log = log.child('db'); * db_log.info('connected'); // [app:db] ➤ connected * * // Custom configuration * const verbose_log = new Logger('debug', { level: 'debug', colors: true }); * ``` */ export declare class Logger { #private; readonly label?: string; readonly parent?: Logger; /** * Creates a new Logger instance. * * @param label - optional label for this logger. Can be `undefined` for no label, or an * empty string `''` which is functionally equivalent (both produce no brackets in output). * Note: Empty strings are only allowed for root loggers - child loggers cannot have empty labels. * @param options - optional configuration for level, colors, and console */ constructor(label?: string, options?: LoggerOptions); /** * Dynamic getter for level - checks override, then parent, then default. */ get level(): LogLevel; /** * Setter for level - creates override. */ set level(value: LogLevel); /** * Dynamic getter for colors - checks override, then parent, then environment variables. * * Colors are disabled if either the `NO_COLOR` or `CLAUDECODE` environment variable is set. * The `CLAUDECODE` check disables colors in Claude Code environments where ANSI color codes * may not render correctly in the output. */ get colors(): boolean; /** * Setter for colors - creates override. */ set colors(value: boolean); /** * Dynamic getter for console - checks override, then parent, then global console. */ get console(): LogConsole; /** * Setter for console - creates override. */ set console(value: LogConsole); /** * Gets the root logger by walking up the parent chain. * Useful for setting global configuration that affects all child loggers. * @returns the root logger (the one without a parent) */ get root(): Logger; /** * Clears the level override for this logger, restoring inheritance from parent. * After calling this, the logger will dynamically inherit the level from its parent * (or use the default level if it has no parent). * @mutates this - clears `#level_override` and the cached `#cached_level_string` / `#cached_level` so subsequent calls walk the parent chain */ clear_level_override(): void; /** * Clears the colors override for this logger, restoring inheritance from parent. * After calling this, the logger will dynamically inherit colors from its parent * (or use the default colors behavior if it has no parent). * @mutates this - clears `#colors_override` and invalidates the cached prefix strings (`#cached_colors`, `#cached_error`, `#cached_warn`, `#cached_info`, `#cached_debug`) so prefixes recompute on next log call */ clear_colors_override(): void; /** * Clears the console override for this logger, restoring inheritance from parent. * After calling this, the logger will dynamically inherit the console from its parent * (or use the global console if it has no parent). */ clear_console_override(): void; /** * Creates a child logger with automatic label concatenation. * Children inherit parent configuration unless overridden. * * @param label - child label (will be concatenated with parent label using `:`) * Cannot be an empty string - empty labels would result in confusing output like `parent:` * with a trailing colon. Use `undefined` or `''` only for root loggers. * @param options - optional configuration overrides * @returns new `Logger` instance with concatenated label * @throws Error if label is an empty string * * @example * ```ts * const app_log = new Logger('app'); * const db_log = app_log.child('db'); // label: 'app:db' * const query_log = db_log.child('query'); // label: 'app:db:query' * ``` */ child(label: string, options?: LoggerOptions): Logger; /** * Logs an error message with `🞩error🞩` prefix. * Only outputs if current level is `error` or higher. */ error(...args: Array): void; /** * Logs a warning message with `⚑warn⚑` prefix. * Only outputs if current level is `warn` or higher. */ warn(...args: Array): void; /** * Logs an informational message. * Unlike error/warn/debug, info has no character prefix - only the label is shown. * This keeps standard output clean since info is the default log level. * Only outputs if current level is `info` or higher. */ info(...args: Array): void; /** * Logs a debug message with `┆debug┆` prefix. * Only outputs if current level is `debug`. */ debug(...args: Array): void; /** * Logs raw output without any prefix, formatting, or level filtering. * Bypasses the logger's level checking, prefix formatting, and color application entirely. * * Note: This method ignores the configured log level - it always outputs regardless of * whether the logger is set to `'off'` or any other level. */ raw(...args: Array): void; } export interface LoggerOptions { /** * Log level for this logger instance. * Inherits from parent or defaults to 'info'. */ level?: LogLevel; /** * Console interface for output. * Inherits from parent or defaults to global console. * Useful for testing. */ console?: LogConsole; /** * Whether to use colors in output. * Inherits from parent or defaults to enabled (unless NO_COLOR env var is set). */ colors?: boolean; } //# sourceMappingURL=log.d.ts.map