mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-13 19:23:14 +00:00
* feat: introduce eslint flag * chore: update logger * chore: update enr * chore: update core * chore: update sdk * chore: update relay * chore: update discovery * chore: update message-encryption * chore: update tests * chore: fix modifiers * chore(tests): fix access modifiers * chore: fix rebase
37 lines
939 B
TypeScript
37 lines
939 B
TypeScript
import debug, { Debugger } from "debug";
|
|
|
|
const APP_NAME = "waku";
|
|
|
|
export class Logger {
|
|
private _info: Debugger;
|
|
private _warn: Debugger;
|
|
private _error: Debugger;
|
|
|
|
private static createDebugNamespace(level: string, prefix?: string): string {
|
|
return prefix ? `${APP_NAME}:${level}:${prefix}` : `${APP_NAME}:${level}`;
|
|
}
|
|
|
|
public constructor(prefix?: string) {
|
|
this._info = debug(Logger.createDebugNamespace("info", prefix));
|
|
this._warn = debug(Logger.createDebugNamespace("warn", prefix));
|
|
this._error = debug(Logger.createDebugNamespace("error", prefix));
|
|
}
|
|
|
|
public get info(): Debugger {
|
|
return this._info;
|
|
}
|
|
|
|
public get warn(): Debugger {
|
|
return this._warn;
|
|
}
|
|
|
|
public get error(): Debugger {
|
|
return this._error;
|
|
}
|
|
|
|
public log(level: "info" | "warn" | "error", ...args: unknown[]): void {
|
|
const logger = this[level] as (...args: unknown[]) => void;
|
|
logger(...args);
|
|
}
|
|
}
|