Clearer iteration through keys
- We needed to closure the variable `levels` and this is cleaner
This commit is contained in:
parent
6520f8c5e6
commit
4415f1c862
1 changed files with 16 additions and 18 deletions
|
|
@ -14,8 +14,7 @@ var levels = {
|
||||||
'fatal': 5
|
'fatal': 5
|
||||||
};
|
};
|
||||||
|
|
||||||
for (_level in levels) {
|
Object.keys(levels).forEach(function(level) {
|
||||||
(function(level) {
|
|
||||||
Logger.prototype[level] = function() {
|
Logger.prototype[level] = function() {
|
||||||
if (levels[level] >= levels[this.level]) {
|
if (levels[level] >= levels[this.level]) {
|
||||||
var str = '[' + level + '] ' + this.name + ': ' + arguments[0],
|
var str = '[' + level + '] ' + this.name + ': ' + arguments[0],
|
||||||
|
|
@ -32,8 +31,7 @@ for (_level in levels) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})(_level);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
Logger.prototype.setLevel = function(level) {
|
Logger.prototype.setLevel = function(level) {
|
||||||
this.level = level;
|
this.level = level;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue