kist
Version:
Package Pipeline Processor
95 lines (94 loc) • 3.18 kB
TypeScript
/**
* Logger class for handling console messages.
* Singleton instance ensures consistent logging behavior throughout the
* application.
*/
export declare class Logger {
/**
* Singleton instance
*/
private static instance;
/**
* Current log level
*/
private logLevel;
/**
* Private constructor to enforce singleton pattern.
* @param logLevel - The log level for controlling log output.
*/
private constructor();
/**
* Retrieves the singleton instance of Logger.
* Initializes a non-verbose Logger instance if it hasn't been explicitly
* initialized.
*
* @returns The Logger instance.
*/
static getInstance(logLevel?: "debug" | "info" | "warn" | "error"): Logger;
/**
* Resets the Logger instance.
* Useful for testing or reinitializing the Logger during runtime.
*/
static resetInstance(): void;
/**
* Logs a message with a specific level if it meets the current log level.
*
* @param level - The log level (e.g., "INFO", "WARN", "ERROR").
* @param context - The context or class name where the log originates.
* @param message - The message content to log.
* @param fgStyle - The foreground color style to apply to the log level.
* @param bgStyle - The background color style to apply to the log level (default is reset).
*/
private log;
/**
* Determines if a log should be displayed based on the current log level.
*
* @param level - The level of the log being checked.
* @returns True if the log should be displayed, otherwise false.
*/
private shouldLog;
/**
* Logs an informational message.
*
* @param context - The originating class or module.
* @param message - The informational message to log.
*/
logInfo(context: string, message: string): void;
/**
* Logs a warning message.
*
* @param context - The originating class or module.
* @param message - The warning message to log.
*/
logWarn(context: string, message: string): void;
/**
* Logs an error message.
*
* @param context - The originating class or module.
* @param message - The error message to log.
* @param error - (Optional) Additional error details.
*/
logError(context: string, message: string, error?: unknown): void;
/**
* Logs a debug message.
*
* @param context - The originating class or module.
* @param message - The debug message to log.
*/
logDebug(context: string, message: string): void;
/**
* Sets the log level dynamically.
*
* @param level - The log level to set (e.g., "debug", "info").
*/
setLogLevel(level: "debug" | "info" | "warn" | "error"): void;
/**
* Formats an error message for logging.
* Combines a base message with additional error details if available.
*
* @param message - The base error message.
* @param error - Additional error information, such as an Error object.
* @returns A formatted string combining the message and error details.
*/
private formatError;
}