UNPKG

logs-interceptor-node14

Version:

High-performance, production-ready log interceptor for Node.js 14 applications with Loki integration

68 lines 2.43 kB
import { LogsInterceptorConfig } from './types'; /** * Safely stringify any value, handling circular references and non-serializable objects */ export declare function safeStringify(value: unknown, maxDepth?: number): string; /** * Detect sensitive data in a string */ export declare function detectSensitiveData(text: string, patterns: RegExp[]): boolean; /** * Sanitize sensitive data from an object */ export declare function sanitizeData(data: Record<string, unknown>, sensitivePatterns: RegExp[]): Record<string, unknown>; /** * Hash sensitive data for tracking without exposing it */ export declare function hashSensitiveData(data: string): string; /** * Parse labels from environment variable string format * Format: "key1=value1,key2=value2" */ export declare function parseLabels(labelsString: string): Record<string, string>; /** * Determine if a log should be sampled based on sampling rate */ export declare function shouldSample(rate: number): boolean; /** * Enhanced sampling with support for different strategies */ export declare function shouldSampleAdvanced(rate: number, strategy?: 'random' | 'deterministic' | 'adaptive', key?: string): boolean; /** * Format bytes to human readable string */ export declare function formatBytes(bytes: number): string; /** * Calculate compression ratio */ export declare function calculateCompressionRatio(original: number, compressed: number): number; /** * Load configuration from environment variables */ export declare function loadConfigFromEnv(): Partial<LogsInterceptorConfig>; /** * Merge configurations with precedence: user config > env config > defaults */ export declare function mergeConfigs(userConfig: Partial<LogsInterceptorConfig>, envConfig: Partial<LogsInterceptorConfig>): Partial<LogsInterceptorConfig>; /** * Validate that required configuration is present */ export declare function validateConfig(config: Partial<LogsInterceptorConfig>): string[]; /** * Create a correlation ID for request tracking */ export declare function createCorrelationId(): string; /** * Extract metadata from Error objects */ export declare function extractErrorMetadata(error: Error): Record<string, unknown>; /** * Parse stack trace to extract useful information */ export declare function parseStackTrace(stack: string): Array<{ function: string; file: string; line: number; column: number; }>; //# sourceMappingURL=utils.d.ts.map