3 function Level(level, levelStr) {
5 this.levelStr = levelStr;
9 * converts given String to corresponding Level
10 * @param {String} sArg String value of Level OR Log4js.Level
11 * @param {Log4js.Level} defaultLevel default Level, if no String representation
12 * @return Level object
15 function toLevel(sArg, defaultLevel) {
19 if (sArg instanceof Level) {
20 module.exports[sArg.toString()] = sArg;
23 if (typeof sArg === "string") {
24 return module.exports[sArg.toUpperCase()] || defaultLevel;
26 return toLevel(sArg.toString());
29 Level.prototype.toString = function() {
33 Level.prototype.isLessThanOrEqualTo = function(otherLevel) {
34 if (typeof otherLevel === "string") {
35 otherLevel = toLevel(otherLevel);
37 return this.level <= otherLevel.level;
40 Level.prototype.isGreaterThanOrEqualTo = function(otherLevel) {
41 if (typeof otherLevel === "string") {
42 otherLevel = toLevel(otherLevel);
44 return this.level >= otherLevel.level;
47 Level.prototype.isEqualTo = function(otherLevel) {
48 if (typeof otherLevel === "string") {
49 otherLevel = toLevel(otherLevel);
51 return this.level === otherLevel.level;
55 ALL: new Level(Number.MIN_VALUE, "ALL"),
56 TRACE: new Level(5000, "TRACE"),
57 DEBUG: new Level(10000, "DEBUG"),
58 INFO: new Level(20000, "INFO"),
59 WARN: new Level(30000, "WARN"),
60 ERROR: new Level(40000, "ERROR"),
61 FATAL: new Level(50000, "FATAL"),
62 MARK: new Level(9007199254740992, "MARK"), // 2^53
63 OFF: new Level(Number.MAX_VALUE, "OFF"),