mirror of
https://github.com/waku-org/js-waku.git
synced 2025-01-15 06:54:14 +00:00
allow filtering based on log levels (#1677)
This commit is contained in:
parent
f82add16ab
commit
81b2bf46ab
@ -67,7 +67,7 @@ export class StreamManager {
|
||||
private handlePeerUpdateStreamPool = (evt: CustomEvent<PeerUpdate>): void => {
|
||||
const peer = evt.detail.peer;
|
||||
if (peer.protocols.includes(this.multicodec)) {
|
||||
this.log.error(`Preemptively opening a stream to ${peer.id.toString()}`);
|
||||
this.log.info(`Preemptively opening a stream to ${peer.id.toString()}`);
|
||||
this.prepareNewStream(peer);
|
||||
}
|
||||
};
|
||||
|
@ -12,13 +12,9 @@ export class Logger {
|
||||
}
|
||||
|
||||
constructor(prefix?: string) {
|
||||
this._info = debug(Logger.createDebugNamespace("INFO", prefix));
|
||||
this._warn = debug(Logger.createDebugNamespace("WARN", prefix));
|
||||
this._error = debug(Logger.createDebugNamespace("ERROR", prefix));
|
||||
|
||||
this._info.log = console.info.bind(console);
|
||||
this._warn.log = console.warn.bind(console);
|
||||
this._error.log = console.error.bind(console);
|
||||
this._info = debug(Logger.createDebugNamespace("info", prefix));
|
||||
this._warn = debug(Logger.createDebugNamespace("warn", prefix));
|
||||
this._error = debug(Logger.createDebugNamespace("error", prefix));
|
||||
}
|
||||
|
||||
get info(): Debugger {
|
||||
@ -32,4 +28,9 @@ export class Logger {
|
||||
get error(): Debugger {
|
||||
return this._error;
|
||||
}
|
||||
|
||||
log(level: "info" | "warn" | "error", ...args: unknown[]): void {
|
||||
const logger = this[level] as (...args: unknown[]) => void;
|
||||
logger(...args);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user