loglow
Version:
A flexible logging utility for Node.js, offering customizable color, style, and timestamp options for enhanced console output.
61 lines (59 loc) • 1.82 kB
TypeScript
/**
* Enumeration for log colors with ANSI escape codes for terminal coloring.
*/
declare enum LogColor {
Red = "\u001B[31m",
Green = "\u001B[32m",
Yellow = "\u001B[33m",
Blue = "\u001B[34m",
Magenta = "\u001B[35m",
Cyan = "\u001B[36m",
White = "\u001B[37m"
}
/**
* Enumeration for log styles with ANSI escape codes to style terminal output.
*/
declare enum LogStyle {
Reset = "\u001B[0m",
Bold = "\u001B[1m",
Dim = "\u001B[2m",
Italic = "\u001B[3m",
Underscore = "\u001B[4m",
Blink = "\u001B[5m",
Reverse = "\u001B[7m"
}
/**
* Class to create and manage a logger with support for colors, styles, and timestamps.
*/
declare class Loglow {
private data;
/**
* Adds a message log entry with optional styling.
* @param {...unknown[]} messages - One or more messages or data to log.
* @returns {this} The instance of Loglow for chaining.
*/
add(...messages: unknown[]): this;
/**
* Adds a timestamp log entry with an optional color or style.
* @param {LogColor | LogStyle} [color=LogStyle.Reset] - The color or style of the timestamp.
* @returns {this} The instance of Loglow for chaining.
*/
addTimestamp(color?: LogColor | LogStyle): this;
/**
* Adds a newline log entry.
* @returns {this} The instance of Loglow for chaining.
*/
addNewline(): this;
/**
* Checks if a given value is a valid LogColor or LogStyle.
* @private
* @param {string} value - The value to check.
* @returns {boolean} True if the value is a valid LogColor or LogStyle, false otherwise.
*/
private isLogColorOrStyle;
/**
* Prints the log entries to the console with appropriate formatting.
*/
print(): void;
}
export { LogColor, LogStyle, Loglow };