Changed toLevel to accept a Log4js.Level (or in fact any object), and try to convert it to a Log4js.Level. Fixes the setLevel asymmetry, where you cannot setLevel(log4js.level.foo)
This commit is contained in:
parent
c8157cef5c
commit
2c7b56853b
@ -5,24 +5,29 @@ function Level(level, levelStr) {
|
||||
|
||||
/**
|
||||
* converts given String to corresponding Level
|
||||
* @param {String} sArg String value of Level
|
||||
* @param {String} sArg String value of Level OR Log4js.Level
|
||||
* @param {Log4js.Level} defaultLevel default Level, if no String representation
|
||||
* @return Level object
|
||||
* @type Log4js.Level
|
||||
*/
|
||||
function toLevel(sArg, defaultLevel) {
|
||||
|
||||
if (sArg === null) {
|
||||
return defaultLevel;
|
||||
}
|
||||
if (sArg === null) {
|
||||
return defaultLevel;
|
||||
}
|
||||
|
||||
if (typeof sArg == "string") {
|
||||
var s = sArg.toUpperCase();
|
||||
if (module.exports[s]) {
|
||||
if (typeof sArg == "string") {
|
||||
var s = sArg.toUpperCase();
|
||||
if (module.exports[s]) {
|
||||
return module.exports[s];
|
||||
}
|
||||
}
|
||||
return defaultLevel;
|
||||
}
|
||||
else {
|
||||
return defaultLevel;
|
||||
}
|
||||
}
|
||||
|
||||
return toLevel(sArg.toString());
|
||||
|
||||
};
|
||||
|
||||
Level.prototype.toString = function() {
|
||||
|
Loading…
Reference in New Issue
Block a user