UNPKG

lever-ui-logger

Version:

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

116 lines 3.75 kB
/** * Transport interfaces and utilities for lever-ui-logger */ import type { LogLevel, LogEventData, Transport } from '../logger/types.js'; export declare const Environment: { /** Check if running in browser environment */ readonly isBrowser: boolean; /** Check if running in Node.js environment */ readonly isNode: boolean; /** Check if running in production environment */ readonly isProduction: boolean; /** Check if console methods support styling */ readonly supportsConsoleStyles: boolean; }; /** * Console transport formatting modes */ export type ConsoleFormatMode = 'json' | 'pretty' | 'compact'; /** * Console transport configuration */ export interface ConsoleTransportConfig { /** Transport name (default: 'console') */ name?: string; /** Formatting mode for output */ format?: ConsoleFormatMode; /** Enable/disable colorized output */ colors?: boolean; /** Enable/disable timestamps */ timestamps?: boolean; /** Timestamp format string */ timestampFormat?: string; /** Enable/disable in production environments */ enableInProduction?: boolean; /** Maximum performance threshold in ms */ performanceThreshold?: number; /** Custom log level to console method mapping */ consoleMethods?: Partial<Record<LogLevel, string>>; } /** * Base transport class with common functionality */ export declare abstract class BaseTransport implements Transport { readonly name: string; readonly config: Record<string, unknown>; constructor(name: string, config?: Record<string, unknown>); /** * Write a log event to this transport */ abstract write(_event: LogEventData): Promise<void> | void; /** * Flush any pending logs (default: no-op) */ flush(): Promise<void> | void; /** * Close the transport and clean up resources (default: no-op) */ close(): Promise<void> | void; /** * Check if transport should be active in current environment */ protected isEnabled(): boolean; /** * Measure performance of a function call */ protected measurePerformance<T>(fn: () => T, threshold?: number): T; } /** * Utility functions for formatting log data */ export declare const Formatters: { /** * Format timestamp with configurable format */ readonly timestamp: (timestamp: number, format?: string) => string; /** * Pretty-print objects with indentation */ readonly prettyObject: (obj: unknown, indent?: number) => string; /** * Compact object representation */ readonly compactObject: (obj: unknown) => string; /** * Get log level priority for comparison */ readonly getLogLevelPriority: (level: LogLevel) => number; }; /** * ANSI color codes for terminal output */ export declare const Colors: { readonly trace: "\u001B[36m"; readonly debug: "\u001B[34m"; readonly info: "\u001B[32m"; readonly warn: "\u001B[33m"; readonly error: "\u001B[31m"; readonly reset: "\u001B[0m"; readonly bold: "\u001B[1m"; readonly dim: "\u001B[2m"; readonly component: "\u001B[35m"; readonly timestamp: "\u001B[90m"; }; /** * Browser console styling */ export declare const BrowserStyles: { readonly trace: "color: #00bcd4; font-weight: normal;"; readonly debug: "color: #2196f3; font-weight: normal;"; readonly info: "color: #4caf50; font-weight: normal;"; readonly warn: "color: #ff9800; font-weight: bold;"; readonly error: "color: #f44336; font-weight: bold;"; readonly component: "color: #9c27b0; font-weight: bold;"; readonly timestamp: "color: #666; font-weight: normal;"; }; //# sourceMappingURL=transport-interface.d.ts.map