simplified levels a bit, converted tests to mocha
This commit is contained in:
@@ -34,35 +34,51 @@ Level.prototype.toString = function() {
|
||||
return this.levelStr;
|
||||
};
|
||||
|
||||
Level.prototype.isLessThanOrEqualTo = function(otherLevel) {
|
||||
if (typeof otherLevel === "string") {
|
||||
otherLevel = toLevel(otherLevel);
|
||||
}
|
||||
return this.level <= otherLevel.level;
|
||||
};
|
||||
function convertAndCompare(comparison) {
|
||||
return function(otherLevel) {
|
||||
if (typeof otherLevel === "string") {
|
||||
otherLevel = toLevel(otherLevel);
|
||||
}
|
||||
return comparison.call(this, otherLevel);
|
||||
};
|
||||
}
|
||||
|
||||
Level.prototype.isGreaterThanOrEqualTo = function(otherLevel) {
|
||||
if (typeof otherLevel === "string") {
|
||||
otherLevel = toLevel(otherLevel);
|
||||
Level.prototype.isLessThanOrEqualTo = convertAndCompare(
|
||||
function(otherLevel) {
|
||||
return this.level <= otherLevel.level;
|
||||
}
|
||||
return this.level >= otherLevel.level;
|
||||
};
|
||||
);
|
||||
|
||||
Level.prototype.isEqualTo = function(otherLevel) {
|
||||
if (typeof otherLevel == "string") {
|
||||
otherLevel = toLevel(otherLevel);
|
||||
Level.prototype.isGreaterThanOrEqualTo = convertAndCompare(
|
||||
function(otherLevel) {
|
||||
return this.level >= otherLevel.level;
|
||||
}
|
||||
return this.level === otherLevel.level;
|
||||
};
|
||||
);
|
||||
|
||||
module.exports = {
|
||||
ALL: new Level(Number.MIN_VALUE, "ALL"),
|
||||
TRACE: new Level(5000, "TRACE"),
|
||||
DEBUG: new Level(10000, "DEBUG"),
|
||||
INFO: new Level(20000, "INFO"),
|
||||
WARN: new Level(30000, "WARN"),
|
||||
ERROR: new Level(40000, "ERROR"),
|
||||
FATAL: new Level(50000, "FATAL"),
|
||||
OFF: new Level(Number.MAX_VALUE, "OFF"),
|
||||
toLevel: toLevel
|
||||
};
|
||||
Level.prototype.isEqualTo = convertAndCompare(
|
||||
function(otherLevel) {
|
||||
return this.level === otherLevel.level;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
exports.ALL = new Level(Number.MIN_VALUE, "ALL");
|
||||
exports.TRACE = new Level(5000, "TRACE");
|
||||
exports.DEBUG = new Level(10000, "DEBUG");
|
||||
exports.INFO = new Level(20000, "INFO");
|
||||
exports.WARN = new Level(30000, "WARN");
|
||||
exports.ERROR = new Level(40000, "ERROR");
|
||||
exports.FATAL = new Level(50000, "FATAL");
|
||||
exports.OFF = new Level(Number.MAX_VALUE, "OFF");
|
||||
|
||||
exports.levels = [
|
||||
exports.OFF,
|
||||
exports.TRACE,
|
||||
exports.DEBUG,
|
||||
exports.INFO,
|
||||
exports.WARN,
|
||||
exports.ERROR,
|
||||
exports.FATAL
|
||||
];
|
||||
|
||||
exports.toLevel = toLevel;
|
||||
|
||||
Reference in New Issue
Block a user