From a79e7667b7ea8a532ae40683ce35cc24f1cd090c Mon Sep 17 00:00:00 2001 From: Alessandro Toppi Date: Fri, 3 Nov 2023 18:38:28 +0100 Subject: [PATCH] logger: set default level to "info" if verbosity string is not matched --- src/utils/logger.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/logger.js b/src/utils/logger.js index 22cfb0b..1f95db8 100644 --- a/src/utils/logger.js +++ b/src/utils/logger.js @@ -12,13 +12,15 @@ import { getCliArgument } from './utils.js'; -const LEVELS_IDX = ['none', 'error', 'warn', 'info', 'verb', 'debug'].reduce((obj, lvl, idx) => { +const LEVELS = ['none', 'error', 'warn', 'info', 'verb', 'debug']; +const LEVELS_IDX = LEVELS.reduce((obj, lvl, idx) => { obj[lvl] = idx; return obj; }, {}); const DEFAULT_LEVEL = 'info'; let log_verbosity = getCliArgument('janode-log', 'string', DEFAULT_LEVEL); +if (LEVELS.indexOf(log_verbosity) < 0) log_verbosity = DEFAULT_LEVEL; const printout = (msg_verbosity, console_fn, ...args) => { if (LEVELS_IDX[msg_verbosity] > LEVELS_IDX[log_verbosity]) return;