cross-log
Version:
A universal logging package that works in both browser and Node.js environments with environment variable configuration
57 lines • 1.89 kB
TypeScript
/**
* Utility functions for the universal logger
*/
import { LogLevel, Environment } from './types';
/**
* Detect the current environment
*/
export declare function detectEnvironment(): Environment;
/**
* Parse log level from string
*/
export declare function parseLogLevel(level?: string): LogLevel | null;
/**
* Parse boolean from environment variable
*/
export declare function parseEnvBoolean(value?: string, defaultValue?: boolean): boolean;
/**
* Parse integer from environment variable
*/
export declare function parseEnvInt(value: string | undefined, defaultValue: number): number;
/**
* Get environment variable with fallback
*/
export declare function getEnvVar(key: string, defaultValue?: string): string | undefined;
/**
* Format timestamp for logging
*/
export declare function formatTimestamp(date?: Date): string;
/**
* Check if logging should be enabled for the specified level
*/
export declare function isLoggingEnabled(currentLevel: LogLevel, messageLevel: LogLevel, globalEnabled: boolean): boolean;
/**
* Format message with category and timestamp
*/
export declare function formatMessage(message: string, category?: string, showTimestamp?: boolean): string;
/**
* Get console method for log level
*/
export declare function getConsoleMethod(level: LogLevel): (message?: unknown, ...optionalParams: unknown[]) => void;
/**
* Create ANSI color code for terminal output
*/
export declare function createAnsiColor(colorCode: number): string;
/**
* Reset ANSI color
*/
export declare function resetAnsiColor(): string;
/**
* Safely stringify an object for logging
*/
export declare function safeStringify(obj: unknown): string;
/**
* Debounce function to prevent log spam
*/
export declare function debounce<T extends (...args: unknown[]) => void>(func: T, wait: number): (...args: Parameters<T>) => void;
//# sourceMappingURL=utils.d.ts.map