Skip to content

Commit

Permalink
logger: set default level to "info" if verbosity string is not matched
Browse files Browse the repository at this point in the history
  • Loading branch information
atoppi committed Nov 3, 2023
1 parent 09d0523 commit a79e766
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/utils/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a79e766

Please sign in to comment.