UNPKG

cross-log

Version:

A universal logging package that works in both browser and Node.js environments with environment variable configuration

99 lines 3.01 kB
/** * Base logger implementation with shared functionality */ import { LoggerConfig, LogLevel, LogEntry, PartialLoggerConfig, ILogger } from '../core/types'; import { ConfigManager } from '../core/config'; import { PluginManager } from '../plugins/manager'; import { Plugin, LoggerWithPlugins } from '../plugins/types'; export declare abstract class BaseLogger implements LoggerWithPlugins { protected configManager: ConfigManager; protected pluginManager: PluginManager; protected recentLogs: Map<string, number>; protected readonly duplicateThreshold = 1000; constructor(initialConfig?: PartialLoggerConfig); /** * Log debug message */ debug(message: string, category?: string, ...args: unknown[]): void; /** * Log informational message */ info(message: string, category?: string, ...args: unknown[]): void; /** * Log warning message */ warn(message: string, category?: string, ...args: unknown[]): void; /** * Log error message or Error object */ error(message: string | Error, category?: string, ...args: unknown[]): void; /** * Set the minimum log level */ setLevel(level: LogLevel): void; /** * Configure the logger */ configure(newConfig: PartialLoggerConfig): void; /** * Enable logging for a specific category */ enableCategory(category: string, minLevel?: LogLevel): void; /** * Disable logging for a specific category */ disableCategory(category: string): void; /** * Enable all logging */ enableAll(): void; /** * Disable all logging */ disableAll(): void; /** * Get the current logger configuration */ getConfig(): LoggerConfig; /** * Check if logging is currently enabled */ isEnabled(): boolean; /** * Log level constants */ get Level(): typeof LogLevel; /** * Use a plugin with the logger */ use(plugin: Plugin): ILogger; /** * Get a plugin instance by name */ getPlugin(name: string): Plugin | undefined; /** * Check if a plugin is loaded */ hasPlugin(name: string): boolean; /** * Remove a plugin */ removePlugin(name: string): void; /** * Core logging method with level checking */ protected logWithLevel(level: LogLevel, message: string | Error, category?: string, ...args: unknown[]): void; /** * Check if this is a duplicate log message */ protected isDuplicateLog(message: string | Error, category?: string): boolean; /** * Abstract method for outputting logs (implemented by subclasses) */ protected abstract outputLog(level: LogLevel, formattedMessage: string, logEntry: LogEntry, ...args: unknown[]): void; /** * Abstract method for outputting stack traces (implemented by subclasses) */ protected abstract outputStackTrace(error: Error): void; } //# sourceMappingURL=base.d.ts.map