2022-06-16 19:06:48 +00:00
|
|
|
// @internal
|
|
|
|
export interface ILogger {
|
|
|
|
info(msg: string): void;
|
|
|
|
success(msg: string): void;
|
|
|
|
warn(msg: string): void;
|
|
|
|
error(msg: string): void;
|
|
|
|
}
|
|
|
|
|
|
|
|
// @internal
|
|
|
|
export class Logger implements ILogger {
|
|
|
|
private colors = {
|
|
|
|
reset: '\x1b[0m',
|
|
|
|
fg: {
|
|
|
|
red: '\x1b[31m',
|
|
|
|
green: '\x1b[32m',
|
|
|
|
yellow: '\x1b[33m',
|
|
|
|
},
|
|
|
|
} as const;
|
|
|
|
|
|
|
|
private packageName: string;
|
|
|
|
|
|
|
|
constructor(packageName: string) {
|
|
|
|
this.packageName = packageName;
|
|
|
|
}
|
|
|
|
|
2022-06-22 15:59:49 +00:00
|
|
|
private log(msg: string, prefix = '') {
|
2022-06-16 19:06:48 +00:00
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.log(`%s${this.packageName}:%s ${msg}\n`, prefix, prefix ? this.colors.reset : '');
|
|
|
|
}
|
|
|
|
|
|
|
|
info(msg: string) {
|
|
|
|
this.log(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
success(msg: string) {
|
|
|
|
this.log(msg, this.colors.fg.green);
|
|
|
|
}
|
|
|
|
|
|
|
|
warn(msg: string) {
|
|
|
|
this.log(`Skipped!\n${msg}`, this.colors.fg.yellow);
|
|
|
|
}
|
|
|
|
|
|
|
|
error(msg: string) {
|
|
|
|
this.log(`Failed!\n${msg}`, this.colors.fg.red);
|
|
|
|
}
|
|
|
|
}
|