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:
+15
-10
@@ -5,24 +5,29 @@ function Level(level, levelStr) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* converts given String to corresponding Level
|
* 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
|
* @param {Log4js.Level} defaultLevel default Level, if no String representation
|
||||||
* @return Level object
|
* @return Level object
|
||||||
* @type Log4js.Level
|
* @type Log4js.Level
|
||||||
*/
|
*/
|
||||||
function toLevel(sArg, defaultLevel) {
|
function toLevel(sArg, defaultLevel) {
|
||||||
|
|
||||||
if (sArg === null) {
|
if (sArg === null) {
|
||||||
return defaultLevel;
|
return defaultLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof sArg == "string") {
|
if (typeof sArg == "string") {
|
||||||
var s = sArg.toUpperCase();
|
var s = sArg.toUpperCase();
|
||||||
if (module.exports[s]) {
|
if (module.exports[s]) {
|
||||||
return module.exports[s];
|
return module.exports[s];
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
return defaultLevel;
|
return defaultLevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return toLevel(sArg.toString());
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Level.prototype.toString = function() {
|
Level.prototype.toString = function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user