2022-11-08 16:44:41 -05:00
|
|
|
import { INitroLogger } from './INitroLogger';
|
2021-03-16 22:02:09 -04:00
|
|
|
|
|
|
|
export class NitroLogger implements INitroLogger
|
|
|
|
{
|
|
|
|
private _name: string;
|
|
|
|
private _description: string | number;
|
|
|
|
private _print: boolean;
|
|
|
|
|
|
|
|
constructor(name: string, description: string | number = null)
|
|
|
|
{
|
2022-03-02 19:21:30 -05:00
|
|
|
this._name = name;
|
|
|
|
this._description = description;
|
|
|
|
this._print = true;
|
2021-03-16 22:02:09 -04:00
|
|
|
}
|
|
|
|
|
2022-07-18 21:51:53 -04:00
|
|
|
public log(...message: any[]): void
|
2021-03-16 22:02:09 -04:00
|
|
|
{
|
2022-07-18 21:51:53 -04:00
|
|
|
this.printMessage('log', ...message);
|
2021-03-16 22:02:09 -04:00
|
|
|
}
|
|
|
|
|
2022-07-18 21:51:53 -04:00
|
|
|
public error(...message: any[]): void
|
2021-03-16 22:02:09 -04:00
|
|
|
{
|
2022-07-18 21:51:53 -04:00
|
|
|
this.printMessage('error', ...message);
|
2021-03-16 22:02:09 -04:00
|
|
|
}
|
|
|
|
|
2022-07-18 21:51:53 -04:00
|
|
|
public warn(...message: any[]): void
|
2021-03-16 22:02:09 -04:00
|
|
|
{
|
2022-07-18 21:51:53 -04:00
|
|
|
this.printMessage('warn', ...message);
|
2021-03-16 22:02:09 -04:00
|
|
|
}
|
|
|
|
|
2022-07-18 21:51:53 -04:00
|
|
|
public printMessage(modus: string, ...message: any[]): void
|
2021-03-16 22:02:09 -04:00
|
|
|
{
|
2022-11-08 16:44:41 -05:00
|
|
|
if (!this._print) return;
|
2021-03-16 22:02:09 -04:00
|
|
|
|
2022-07-18 21:51:53 -04:00
|
|
|
NitroLogger.log(this._name, modus, ...message);
|
2021-03-16 22:02:09 -04:00
|
|
|
}
|
|
|
|
|
2022-11-08 16:44:41 -05:00
|
|
|
private static logPrefix(): string
|
2021-03-16 22:02:09 -04:00
|
|
|
{
|
2022-11-08 16:44:41 -05:00
|
|
|
return '[Nitro]';
|
|
|
|
}
|
2021-03-16 22:02:09 -04:00
|
|
|
|
2022-11-08 16:44:41 -05:00
|
|
|
public static log(...messages: any[]): void
|
|
|
|
{
|
|
|
|
console.log(this.logPrefix(), ...messages);
|
2021-03-16 22:02:09 -04:00
|
|
|
}
|
|
|
|
|
2022-11-08 16:44:41 -05:00
|
|
|
public static error(...messages: any[]): void
|
2022-03-21 01:53:14 -04:00
|
|
|
{
|
2022-11-08 16:44:41 -05:00
|
|
|
console.error(this.logPrefix(), ...messages);
|
2022-03-21 01:53:14 -04:00
|
|
|
}
|
|
|
|
|
2022-11-08 16:44:41 -05:00
|
|
|
public static warn(...messages: any[]): void
|
2021-03-16 22:02:09 -04:00
|
|
|
{
|
2022-11-08 16:44:41 -05:00
|
|
|
console.warn(this.logPrefix(), ...messages);
|
2021-03-16 22:02:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public get description(): string | number
|
|
|
|
{
|
|
|
|
return this._description;
|
|
|
|
}
|
|
|
|
|
|
|
|
public set description(description: string | number)
|
|
|
|
{
|
|
|
|
this._description = description;
|
|
|
|
}
|
|
|
|
|
|
|
|
public get print(): boolean
|
|
|
|
{
|
|
|
|
return this._print;
|
|
|
|
}
|
|
|
|
|
|
|
|
public set print(flag: boolean)
|
|
|
|
{
|
|
|
|
this._print = flag;
|
|
|
|
}
|
|
|
|
}
|