error message if log level is set with wrong name (#5805)

This commit is contained in:
Eugenio Romano
2020-06-22 18:46:45 +01:00
committed by GitHub
parent adfa9e2d80
commit 9a156fa4fe
+13 -4
View File
@@ -65,10 +65,19 @@ export class Logger {
}
private static getLogLevelByName(name: string): number {
const log = logLevels.find((currentLog) => {
return currentLog.name === name;
});
if (name) {
const log = logLevels.find((currentLog) => {
return currentLog.name === name;
});
return log.level || 1;
if (log && log.level) {
return log.level;
} else {
console.error(errorColor, 'Log level not correctly set, use one of the following values TRACE|DEBUG|INFO|WARN|ERROR|SILENT');
return LogLevelsEnum.ERROR;
}
} else {
return LogLevelsEnum.ERROR;
}
}
}