How to use the js-logger.setLevel function in js-logger

To help you get started, we’ve selected a few js-logger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github archilogic-com / 3dio-js / src / core / configs.js View on Github external
function setLogLevel (val) {
  // update logger
  var logLevelEnum = LOG_STRING_TO_ENUM[val]
  if (logLevelEnum) {
    // set log level
    log.setLevel(logLevelEnum)
    configs.logLevel = val
  } else {
    // handle error
    var errorMessage = 'Unknown log level "' + val + '". Possible are: "' + Object.keys(LOG_STRING_TO_ENUM).join('", "') + '". '
    if (configs.logLevel) {
      // do not change current log level
      errorMessage += 'Log level remains "' + configs.logLevel
    } else {
      // set default log level
      var defaultVal = defaults.logLevel
      errorMessage += 'Fallback to default "' + defaultVal + '".'
      log.setLevel(LOG_STRING_TO_ENUM[defaultVal])
      configs.logLevel = defaultVal
    }
    console.error(errorMessage)
  }
github archilogic-com / 3dio-js / src / core / configs.js View on Github external
var logLevelEnum = LOG_STRING_TO_ENUM[val]
  if (logLevelEnum) {
    // set log level
    log.setLevel(logLevelEnum)
    configs.logLevel = val
  } else {
    // handle error
    var errorMessage = 'Unknown log level "' + val + '". Possible are: "' + Object.keys(LOG_STRING_TO_ENUM).join('", "') + '". '
    if (configs.logLevel) {
      // do not change current log level
      errorMessage += 'Log level remains "' + configs.logLevel
    } else {
      // set default log level
      var defaultVal = defaults.logLevel
      errorMessage += 'Fallback to default "' + defaultVal + '".'
      log.setLevel(LOG_STRING_TO_ENUM[defaultVal])
      configs.logLevel = defaultVal
    }
    console.error(errorMessage)
  }
}