UNPKG

traceperf

Version:

High-performance function execution tracking and monitoring for Node.js

98 lines (97 loc) 2.86 kB
import { ILogger, ILoggerConfig, LogMode, ITrackOptions } from '../types'; /** * Main logger class that implements the ILogger interface */ export declare class Logger implements ILogger { private _config; private _executionTracker; private _performanceMonitor; private _indentLevel; private _transports; private _formatters; /** * Create a new Logger instance * * @param config - Logger configuration */ constructor(config?: Partial<ILoggerConfig>); /** * Log an informational message * * @param message - The message to log * @param args - Additional arguments to include in the log */ info(message: string | object, ...args: any[]): void; /** * Log a warning message * * @param message - The message to log * @param args - Additional arguments to include in the log */ warn(message: string | object, ...args: any[]): void; /** * Log an error message * * @param message - The message to log * @param args - Additional arguments to include in the log */ error(message: string | object, ...args: any[]): void; /** * Log a debug message * * @param message - The message to log * @param args - Additional arguments to include in the log */ debug(message: string | object, ...args: any[]): void; /** * Start a new log group with the given label * * @param label - The label for the group */ group(label: string): void; /** * End the current log group */ groupEnd(): void; /** * Set the operational mode for the logger * * @param mode - The mode to set */ setMode(mode: LogMode): void; /** * Get the current operational mode * * @returns The current mode */ getMode(): LogMode; /** * Track the execution of a function * * @param fn - The function to track * @param options - Options for tracking * @returns The return value of the tracked function */ track<T>(fn: () => T, options?: ITrackOptions): T; /** * Create a trackable version of a function * * This is a helper method to create a tracked version of a function * that can be used for nested function tracking. * * @param fn - The function to make trackable * @param options - Options for tracking * @returns A tracked version of the function */ createTrackable<T extends (...args: any[]) => any>(fn: T, options?: Omit<ITrackOptions, 'label'> & { label?: string; }): (...args: Parameters<T>) => ReturnType<T>; /** * Internal method to log a message * * @param level - The log level * @param message - The message to log * @param args - Additional arguments */ private log; }