Danish Arora 169a09d552
chore: enforce access modifiers (#2068)
* 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
2024-07-19 15:58:17 +05:30

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);
}
}