-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogger.ts
More file actions
27 lines (21 loc) · 760 Bytes
/
Copy pathLogger.ts
File metadata and controls
27 lines (21 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
export default class Logger {
public static baseConfig: { baseColor: string | null } = {
baseColor: "#FFB6C1",
};
public baseColor: string | null = null;
constructor(public name: string) {}
private createPrefix(c?: string | null): [string, string] {
let color = c || this.baseColor || Logger.baseConfig.baseColor;
return [`%c[${this.name}] =>`, `font-weight: bold; color: ${color}`];
}
public log(...logs: any[]): void {
console.log(...this.createPrefix(), ...logs);
}
public error(...logs: any[]): void {
console.log(...this.createPrefix("#FF0000"), ...logs);
}
public warn(...logs: any[]): void {
console.log(...this.createPrefix("#FFFF00"), ...logs);
}
}
export const defaultLogger = new Logger("log");