2024-08-17 01:39:16 -04:00
|
|
|
import chalk from "chalk";
|
|
|
|
|
|
|
|
export class Logger {
|
|
|
|
private _wrn: string;
|
|
|
|
private _err: string;
|
|
|
|
private _main: string;
|
|
|
|
|
2024-08-18 17:17:59 -04:00
|
|
|
constructor(origin?: string) {
|
2024-08-17 01:39:16 -04:00
|
|
|
this._wrn = chalk.yellow("[WARN] ");
|
|
|
|
this._err = chalk.red("[ERROR] ");
|
|
|
|
|
2024-08-21 01:25:49 -04:00
|
|
|
this._main = chalk.bold.gray(`[Simple Review Server | ${emp(origin ?? "Anonymous")}] `);
|
2024-08-17 01:39:16 -04:00
|
|
|
}
|
|
|
|
|
2024-08-18 17:11:15 -04:00
|
|
|
public log(text: any, args?: any): void {
|
2024-08-17 12:56:35 -04:00
|
|
|
args
|
|
|
|
? console.log(this._main + text, args)
|
|
|
|
: console.log(this._main + text);
|
2024-08-17 01:39:16 -04:00
|
|
|
}
|
|
|
|
|
2024-08-18 17:11:15 -04:00
|
|
|
public warn(text: any, args?: any): void {
|
2024-08-17 12:56:35 -04:00
|
|
|
args
|
2024-08-18 17:14:59 -04:00
|
|
|
? console.warn(this._main + this._wrn + text, args)
|
|
|
|
: console.warn(this._main + this._wrn + text);
|
2024-08-17 01:39:16 -04:00
|
|
|
}
|
|
|
|
|
2024-08-18 17:11:15 -04:00
|
|
|
public error(text: any, args?: any): void {
|
2024-08-17 12:56:35 -04:00
|
|
|
args
|
2024-08-18 17:14:59 -04:00
|
|
|
? console.error(this._main + this._err + text, args)
|
|
|
|
: console.error(this._main + this._err + text);
|
2024-08-17 01:39:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const emp = chalk.green;
|
|
|
|
export const wrn = chalk.yellow;
|
|
|
|
export const err = chalk.red;
|
2024-08-18 23:44:22 -04:00
|
|
|
|
|
|
|
export const bold = chalk.bold;
|
|
|
|
export const itl = chalk.italic;
|
|
|
|
export const udln = chalk.underline;
|