/** * Logger Module - High-Performance Cross-Platform Logging with Pino * * Features: * - High-performance structured logging powered by Pino * - Pretty-printing in development with pino-pretty * - JSON structured output in production for log aggregation * - Hierarchical category-specific loggers with independent levels * - Auto-initialization with environment variables on module load * - Configuration-driven setup with level filtering * - Environment variable support for per-category log levels (e.g., LOG_CORE_DB=debug) * - Backward compatible API with previous console-based logger * * Categories: Dot-separated hierarchies (e.g., "core.db", "api.handler.users") * Usage: Auto-initialized on import → createCategoryLogger(category, bindings?) * * Environment Variable Support: * - Set per-category log level with LOG_{CATEGORY} (e.g., LOG_CORE_DB=debug) * - Category name normalization: dots preserved for hierarchy, other non-alphanumeric characters become dots * - Hierarchical resolution: most-specific match wins (e.g., LOG_CORE_DB > LOG_CORE > LOG_LEVEL) * - Any LOG_{CATEGORY} variable is supported dynamically (no fixed list) * - These override global LOG_LEVEL and config.categoryLevels * - LOG_LEVEL sets the global default if no category override is present * * Auto-Initialization: * - Logger automatically scans environment variables when module is imported * - No manual initialization required for basic usage * - initializeLogger() can still be used to override settings * * Implementation: Pino-based structured logging with performance optimizations * - Development: Pretty-printed colored output via pino-pretty * - Production: JSON structured logs for log aggregation systems * * Recent Changes: * - 2026-02-28: Added pre-created canonical feature-path categories (`turn.trace`, `llm.prep`, `llm.request.*`, `llm.response.*`, `tool.call.*`, `tool.continuation`, `message.publish`). */ export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error'; export interface Logger { trace: (msg: any, ...args: any[]) => void; debug: (msg: any, ...args: any[]) => void; info: (msg: any, ...args: any[]) => void; warn: (msg: any, ...args: any[]) => void; error: (msg: any, ...args: any[]) => void; child: (bindings: Record) => Logger; level: LogLevel; } export declare function addLogStreamCallback(callback: (logEvent: import('./subscription.js').LogStreamEvent) => void): () => void; export interface LoggerConfig { globalLevel?: LogLevel; categoryLevels?: Record; } export declare function initializeLogger(config?: LoggerConfig): void; export declare function createCategoryLogger(category: string, bindings?: Record): Logger; export declare function getCategoryLogLevel(category: string): LogLevel; export declare function shouldLogForCategory(messageLevel: LogLevel, category: string): boolean; export declare const logger: Logger; export declare const loggers: { storage: Logger; 'storage.migration': Logger; 'storage.query': Logger; 'storage.memory': Logger; 'storage.init': Logger; mcp: Logger; 'mcp.lifecycle': Logger; 'mcp.connection': Logger; 'mcp.tools': Logger; 'mcp.execution': Logger; llm: Logger; 'llm.prep': Logger; 'llm.request.meta': Logger; 'llm.request.raw': Logger; 'llm.response.meta': Logger; 'llm.response.raw': Logger; 'llm.openai': Logger; 'llm.anthropic': Logger; 'llm.google': Logger; chat: Logger; 'chat.session': Logger; world: Logger; 'world.lifecycle': Logger; 'world.subscription': Logger; 'world.activity': Logger; agent: Logger; 'agent.lifecycle': Logger; events: Logger; 'events.publish': Logger; 'events.agent': Logger; 'events.response': Logger; 'events.memory': Logger; 'turn.trace': Logger; 'tool.call.request': Logger; 'tool.call.response': Logger; 'tool.call.error': Logger; 'tool.continuation': Logger; 'message.publish': Logger; api: Logger; server: Logger; cli: Logger; ws: Logger; }; export default logger;