@hack4impact/logger
Version:
The lightweight & lightning-fast Logger Utility used by Hack4Impact Projects
125 lines (124 loc) • 2.87 kB
TypeScript
import { LogMessage } from "./index";
/**
* The message or nested output
*/
export declare type OutputMessage = LogMessage | Output;
/**
* Store and flush a series of outputs synchronously
*/
export declare class Output {
/**
*
* ANSI Escape Sequences
*
* @example
* ```javascript
* const bold = Output.Colors.Bright;
* ```
*/
static readonly COLORS: {
Reset: string;
Bright: string;
Dim: string;
Underscore: string;
Blink: string;
Reverse: string;
Hidden: string;
FgBlack: string;
FgRed: string;
FgGreen: string;
FgYellow: string;
FgBlue: string;
FgMagenta: string;
FgCyan: string;
FgWhite: string;
BgBlack: string;
BgRed: string;
BgGreen: string;
BgYellow: string;
BgBlue: string;
BgMagenta: string;
BgCyan: string;
BgWhite: string;
};
/**
*
* All messages or nested outputs of this Output instance
*
*/
private _output;
/**
*
* All messages or nested outputs of this Output instance
*
*/
get output(): OutputMessage[];
/**
*
* All messages or nested outputs of this Output instance
*
*/
set output(newOutput: OutputMessage[]);
/**
*
* Adds a message to the output array
*
* @param value - The message to add
* @example
* ```javascript
* new Output().log("hi");
* ```
*/
log<T extends LogMessage>(value: T): T;
/**
*
* Adds a line break to the output array
*
* @example
* ```javascript
* new Output().line();
* ```
*/
line(): void;
/**
*
* Adds a colored message to the output array
*
* @param color - The color to log in
* @param message - The message to add
* @param afterColored - The optional message after the colored message (on the same line)
* @returns The colored log message
* @example
* ```javascript
* new Output().coloredLog("BgBlue", "hi");
* ```
* @example
* ```javascript
* new Output().coloredLog("FgYellow", "hi", "this string will not be colored");
* ```
*/
coloredLog(color: keyof typeof Output.COLORS, message: LogMessage, afterColored?: string): string;
/**
*
* Adds a nested output instance to the output array
*
* @returns The nested output
* @example
* ```javascript
* const nested = new Output().nested();
* ```
*/
nested(): Output;
/**
*
* Logs all messages in the output array
*
* @returns The output array
* @example
* ```javascript
* new Output().flush();
* ```
*/
flush(): OutputMessage[];
}
export default Output;