Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / log4js / lib / levels.js
1 "use strict";
2
3 function Level(level, levelStr) {
4   this.level = level;
5   this.levelStr = levelStr;
6 }
7
8 /**
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
13  * @type Log4js.Level
14  */
15 function toLevel(sArg, defaultLevel) {
16   if (!sArg) {
17     return defaultLevel;
18   }
19   if (sArg instanceof Level) {
20     module.exports[sArg.toString()] = sArg;
21     return sArg;
22   }
23   if (typeof sArg === "string") {
24     return module.exports[sArg.toUpperCase()] || defaultLevel;
25   }
26   return toLevel(sArg.toString());
27 }
28
29 Level.prototype.toString = function() {
30   return this.levelStr;
31 };
32
33 Level.prototype.isLessThanOrEqualTo = function(otherLevel) {
34   if (typeof otherLevel === "string") {
35     otherLevel = toLevel(otherLevel);
36   }
37   return this.level <= otherLevel.level;
38 };
39
40 Level.prototype.isGreaterThanOrEqualTo = function(otherLevel) {
41   if (typeof otherLevel === "string") {
42     otherLevel = toLevel(otherLevel);
43   }
44   return this.level >= otherLevel.level;
45 };
46
47 Level.prototype.isEqualTo = function(otherLevel) {
48   if (typeof otherLevel === "string") {
49     otherLevel = toLevel(otherLevel);
50   }
51   return this.level === otherLevel.level;
52 };
53
54 module.exports = {
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"),
64   toLevel: toLevel,
65   Level: Level
66 };