/** * Logger - Centralized logging with configurable levels * * IMPORTANT: Never use console.* directly in game code (except in Logger implementation, * crash fallback, or dev utilities). Always use Logger methods with optional chaining. */ type LogLevel = "debug" | "info" | "warn" | "error"; interface LoggerConfig { isDebugEnabled: () => boolean; getLogLevel: () => LogLevel; } interface LoggerInterface { debug(message: string, context?: string): void; info(message: string, context?: string): void; warn(message: string, context?: string): void; error(message: string, error?: Error, context?: string): void; group(title: string, callback: () => T): T; time(label: string, callback: () => T): T; createChildLogger?: (context: string) => LoggerInterface; } declare class Logger implements LoggerInterface { private readonly config; private readonly levels; private filtersCached; private cachedIncludes; private cachedExcludes; constructor(config?: LoggerConfig | null); /** * Cache filter configuration on first use. * Filters only change on page reload, so no need to re-read every call. */ private ensureFiltersCached; /** * Check if logging is enabled for the given level */ private shouldLog; /** * Format log message with timestamp and context */ private formatMessage; /** * Determine if this log line should pass include/exclude filters. * Uses cached filter configuration for performance. */ private passesFilters; /** * Debug level logging */ debug(message: string, context?: string): void; /** * Info level logging */ info(message: string, context?: string): void; /** * Warning level logging */ warn(message: string, context?: string): void; /** * Error level logging */ error(message: string, error?: Error, context?: string): void; /** * Group logging operations */ group(title: string, callback: () => T): T; /** * Time a logging operation */ time(label: string, callback: () => T): T; /** * Create a child logger with a specific context */ createChildLogger(context: string): LoggerInterface; } export { type LogLevel, Logger, type LoggerConfig, type LoggerInterface };