Skip to content

Commit

Permalink
refactor(logger): minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanccn committed Jun 7, 2023
1 parent 1affd65 commit b3ecdf1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/lib/logger.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { blue, dim, green, red, yellow } from "kleur/colors";

export class Logger {
prefixSuffix?: string;
private prefixSuffix?: string;

constructor(prefix?: string) {
this.prefixSuffix = prefix ? dim(`:${prefix}`) : "";
this.prefixSuffix = prefix ? dim(`[${prefix}]`) : "";
}

info(...a: unknown[]) {
Expand All @@ -22,6 +22,11 @@ export class Logger {
error(...a: unknown[]) {
console.error(`${red("error")}${this.prefixSuffix} ${dim("·")}`, ...a);
}

fatal(...a: unknown[]) {
console.error(`${red("fatal")}${this.prefixSuffix} ${dim("·")}`, ...a);
process.exit(1);
}
}

export const defaultLogger = new Logger();

0 comments on commit b3ecdf1

Please sign in to comment.