From 101421c4c32653acea5517e7e45d7d594aea8c86 Mon Sep 17 00:00:00 2001 From: n loewen Date: Sat, 2 Sep 2023 20:36:59 -0700 Subject: [PATCH] dbg - Add 'set level' function --- src/dbg.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dbg.js b/src/dbg.js index 55f73a1..cb585dd 100644 --- a/src/dbg.js +++ b/src/dbg.js @@ -3,6 +3,12 @@ module.exports = class DBG { * @param ${'none'|'warn'|'info'|'debug'|'nitpick'} [level='info'] **/ constructor(level = 'info') { + this.setLevel(level); + } + + _levels = ['nitpick', 'debug', 'info', 'warn', 'none']; + + setLevel(level) { if (this._levels.includes(level)) { this._level = level; } else { @@ -10,8 +16,6 @@ module.exports = class DBG { } } - _levels = ['nitpick', 'debug', 'info', 'warn', 'none']; - /** @param {any} s **/ warn = (s='', ...z) => { if (this._lvl2num('warn') < this._lvl2num(this._level)) return