Clearer iteration through keys

- We needed to closure the variable `levels` and this is cleaner
This commit is contained in:
Esteban Ordano 2014-09-01 17:43:02 -03:00
parent 6520f8c5e6
commit 4415f1c862
1 changed files with 16 additions and 18 deletions

View File

@ -14,8 +14,7 @@ var levels = {
'fatal': 5
};
for (_level in levels) {
(function(level) {
Object.keys(levels).forEach(function(level) {
Logger.prototype[level] = function() {
if (levels[level] >= levels[this.level]) {
var str = '[' + level + '] ' + this.name + ': ' + arguments[0],
@ -32,8 +31,7 @@ for (_level in levels) {
}
}
};
})(_level);
}
});
Logger.prototype.setLevel = function(level) {
this.level = level;