UNPKG

cross-log

Version:

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

80 lines 2.47 kB
/** * Base logger implementation with shared functionality */ import { ILogger, LoggerConfig, LogLevel, LogEntry } from '../core/types'; import { ConfigManager } from '../core/config'; export declare abstract class BaseLogger implements ILogger { protected configManager: ConfigManager; protected recentLogs: Map<string, number>; protected readonly duplicateThreshold = 1000; constructor(initialConfig?: Partial<LoggerConfig>); /** * 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: Partial<LoggerConfig>): 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; /** * 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