Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
}
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)
}
}