How to use the setDefaultLevel function from loglevel

Find comprehensive JavaScript loglevel.setDefaultLevel code examples handpicked from public code repositorys.

1
2
3
4
5
6
7
8
9

// setup log level
const log = require('loglevel');

if (process.env.NODE_LOG_LEVEL) {
  log.setDefaultLevel(process.env.NODE_LOG_LEVEL);
} else {
  log.setDefaultLevel('info');
}
fork icon8
star icon1
watch icon8

+ 3 other calls in file

30
31
32
33
34
35
36
37
38
if (!couchdbUrl || !postgresqlUrl) {
  program.help();
}

if (program.verbose) {
  log.setDefaultLevel('debug');
} else {
  log.setDefaultLevel('info');
}
fork icon3
star icon10
watch icon15

+ 3 other calls in file

168
169
170
171
172
173
174
175
176
  lightNode,
  blocksToKeep,
} = conf;
javascriptVMTimeout = conf.javascriptVMTimeout; // eslint-disable-line prefer-destructuring
enableHashVerification = conf.enableHashVerification; // eslint-disable-line prefer-destructuring
log.setDefaultLevel(conf.defaultLogLevel ? conf.defaultLogLevel : 'warn');

database = new Database();
await database.init(databaseURL, databaseName, lightNode, blocksToKeep);
fork icon7
star icon8
watch icon0

90
91
92
93
94
95
96
97
98
99
  prefix.apply(mlog.getLogger('critical'), {
    format (level, name, timestamp) {
      return chalk.red.bold(`[${timestamp}] ${level} ${name}:`)
    }
  })
  mlog.setDefaultLevel('info')
  log.info(`${myModName}: setup.`)
}

exports.setup = setup
fork icon0
star icon2
watch icon2

465
466
467
468
469
470
471
472
473
474
.action(
  tryOrExit(async ({ args, options }) => {
    const { locale } = args;
    const { verbose } = options;
    if (verbose) {
      log.setDefaultLevel(log.levels.DEBUG);
    }
    for (const l of locale) {
      const {
        movedDocs,
fork icon3
star icon1
watch icon0

33
34
35
36
37
38
39
40
41
    }
  },
  options
)

log.setDefaultLevel('error')
log.setLevel(options.logLevel)

const bus = new EventBus(log)
fork icon0
star icon1
watch icon0