@nanocollective/nanocoder
Version:
A local-first CLI coding agent that brings the power of agentic coding tools like Claude Code and Gemini CLI to local models or controlled APIs like OpenRouter
98 lines • 3.02 kB
TypeScript
/**
* Logger Provider - Implements dependency injection pattern for logging
* This file provides centralized logger management without circular dependencies
*/
import type { Logger, LoggerConfig, LogLevel } from './types.js';
export declare class LoggerProvider {
private static instance;
private _logger;
private _config;
private _fallbackInitialized;
private _realDependenciesLoaded;
private _createPinoLogger;
private _createConfig;
private constructor();
/**
* Detect if running under Bun runtime
* Bun's worker threads are incompatible with Pino's transport API
*/
private static isBunRuntime;
/**
* Get the singleton logger provider instance
*/
static getInstance(): LoggerProvider;
/**
* Initialize lazy-loaded dependencies to avoid circular imports
*/
private ensureDependenciesLoaded;
/**
* Asynchronously load real Pino dependencies
* Uses dynamic imports to avoid circular dependency issues
*/
private loadRealDependencies;
/**
* Get the default log level based on environment
* Single source of truth for log level defaults (used before config.ts loads)
*
* IMPORTANT: The fallback logger outputs to console, so in production we use
* 'silent' to avoid polluting the UI. Once the real pino logger loads
* (which writes to files), it will use 'info' level from config.ts.
*/
private getDefaultLogLevel;
/**
* Create fallback config when config.ts hasn't loaded yet
* Uses getDefaultLogLevel() for consistent defaults
*/
private createFallbackConfig;
/**
* Create fallback logger when dependencies fail to load
*/
private createFallbackLogger;
/**
* Create default configuration based on environment
* Delegates to config.ts when loaded, otherwise uses createFallbackConfig
*/
private createDefaultConfig;
/**
* Initialize the logger with configuration
*/
initializeLogger(config?: Partial<LoggerConfig>): Logger;
/**
* Get the current logger instance
*/
getLogger(): Logger;
/**
* Get the current configuration
*/
getLoggerConfig(): LoggerConfig | null;
/**
* Create a child logger with additional context
*/
createChildLogger(bindings: Record<string, unknown>): Logger;
/**
* Format error for structured logging
*/
private formatErrorForLogging;
/**
* Check if a log level is enabled
*/
isLevelEnabled(level: LogLevel): boolean;
/**
* Reset the logger instance (useful for testing)
*/
reset(): void;
/**
* Flush any pending logs
*/
flush(): Promise<void>;
/**
* Flush logs synchronously (for signal handlers)
*/
flushSync(): void;
/**
* End the logger and close all streams
*/
end(): Promise<void>;
}
export declare const loggerProvider: LoggerProvider;
//# sourceMappingURL=logger-provider.d.ts.map