logging-pretty
Version:
Logging your message with pretty color with node.js
129 lines (126 loc) • 3.23 kB
text/typescript
import chalk from 'chalk';
/**
* Interface for Logger options
*/
type TypeArgs = string | null;
type TypeForce = `console` | `file` | `all`;
type LoggerOptions = {
pathFile?: TypeArgs;
force?: TypeForce;
formatTime?: string;
};
/**
* Logger class for handling logging functionality
*/
declare class LoggingPretty {
private pathFile?;
private force;
private formatTime;
private isHavePathFile;
/**
* Create a new Logger instance
*
* @param options Logger configuration options
*/
constructor(options?: LoggerOptions);
/**
* Get current time in specified format
*
* @param format Time format string
* @returns Formatted time string
*/
_getTimeNow(format: string): string;
/**
* Default method for rendering logs to console
* Override this method to customize console output
*
* @param logData Log data object
*/
_renderLogToConsole(logData: {
strTime: string;
strTag: string;
strStyleTag: string;
strMsg: string;
strStyleMsg: string;
}): void;
/**
* Default method for writing logs to file
* Override this method to customize file output
*
* @param logData Log data object
*/
_writeLogToFile(logData: {
strTime: string;
strTag: string;
strStyleTag: string;
strMsg: string;
strStyleMsg: string;
}): void;
/**
* Render log message with formatting
*
* @param strTag Log tag (e.g., INFO, ERROR)
* @param strMsg Log message
* @param colorTag Function to color the tag
* @param colorMsg Function to color the message
*/
_log(strTag: string, strMsg: string, colorTag: any, colorMsg: any): void;
/**
* Log an info message
* @param msg Message to log
*/
info(msg: string): void;
/**
* Log a warning message
* @param msg Message to log
*/
warn(msg: string): void;
/**
* Log an error message
* @param msg Message to log
*/
error(msg: string): void;
/**
* Log a success message
* @param msg Message to log
*/
success(msg: string): void;
/**
* Log a failed message
* @param msg Message to log
*/
failed(msg: string): void;
/**
* Log a fail message
* @param msg Message to log
*/
fail(msg: string): void;
/**
* Log a debug message
* @param msg Message to log
*/
debug(msg: string): void;
/**
* Log a trace message
* @param msg Message to log
*/
trace(msg: string): void;
/**
* Log a fatal message
* @param msg Message to log
*/
fatal(msg: string): void;
/**
* Log a custom message with custom tag and colors
* @param tag Custom tag
* @param msg Message to log
* @param colorUniqTag Function to color the tag
* @param colorMsg Function to color the message
*/
custom(tag: string, msg: string, colorUniqTag?: chalk.Chalk, colorMsg?: chalk.Chalk): void;
/**
* Get the chalk instance for custom coloring
*/
get _listColor(): typeof chalk;
}
export { LoggingPretty, LoggingPretty as default };