simple-review-server/src/utils/logger.ts

41 lines
1,005 B
TypeScript
Raw Normal View History

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:36:33 -04:00
this._main = chalk.bold.gray(`[SRS | ${emp(origin ?? "Anonymous")}] `);
2024-08-17 01:39:16 -04:00
}
public log(text: any, args?: any): void {
args
? console.log(this._main + text, args)
: console.log(this._main + text);
2024-08-17 01:39:16 -04:00
}
public warn(text: any, args?: any): void {
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
}
public error(text: any, args?: any): void {
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;
export const bold = chalk.bold;
export const itl = chalk.italic;
export const udln = chalk.underline;