UNPKG

lever-ui-logger

Version:

Zero-dependency logging library with optional EventBus integration. Built-in PII redaction, multiple transports, and comprehensive logging capabilities.

90 lines 2.62 kB
/** * Console Transport with Advanced Formatting * * Cross-platform console transport that provides rich formatting, colorization, * and environment-specific optimizations. Supports both browser and Node.js * environments with appropriate styling and performance considerations. * * Features: * - Cross-platform support (browser/Node.js) * - Rich formatting with colors and styling * - Multiple format modes (pretty, compact, json) * - Performance monitoring and timing * - Level-specific console methods * - Grouping and indentation support * - Buffer management and flush control * * @example * ```typescript * import { ConsoleTransport } from '@nuanced-labs/lever-ui-logger'; * * // Basic console transport * const transport = new ConsoleTransport({ * level: 'info', * format: 'pretty', * colors: true, * timestamps: true * }); * * // Compact format for production * const compact = new ConsoleTransport({ * format: 'compact', * colors: false, * includeStack: false * }); * * // JSON format for log aggregation * const jsonTransport = new ConsoleTransport({ * format: 'json', * includeMetadata: true, * prettyPrint: false * }); * ``` */ import type { LogEventData } from '../logger/types.js'; import { BaseTransport, type ConsoleTransportConfig } from './transport-interface.js'; /** * Console transport that outputs logs to the console with formatting and colors */ export declare class ConsoleTransport extends BaseTransport { private readonly transportConfig; private readonly consoleMethods; constructor(config?: ConsoleTransportConfig); /** * Write a log event to the console */ write(event: LogEventData): void; /** * Check if transport should be active in current environment */ protected isEnabled(): boolean; /** * Initialize console method mapping */ private initializeConsoleMethods; /** * Format a log event according to the configured format */ private formatEvent; /** * Format data based on the configured format mode */ private formatData; /** * Write to console with browser CSS styles */ private writeWithBrowserStyles; /** * Write to console with ANSI colors */ private writeWithAnsiColors; /** * Write to console without colors */ private writeWithoutColors; } /** * Create a console transport with default configuration */ export declare function createConsoleTransport(config?: ConsoleTransportConfig): ConsoleTransport; //# sourceMappingURL=console-transport.d.ts.map