added masylum's coloured layout function

This commit is contained in:
csausdev
2010-12-05 11:36:35 +08:00
committed by Gareth Jones
parent 838f0c8f28
commit 80e3ed7174
3 changed files with 85 additions and 17 deletions

View File

@@ -188,7 +188,24 @@ vows.describe('log4js').addBatch({
var message = args[1];
assert.equal(message, 'this is a test');
}
},
'colouredLayout': {
topic: function() {
return require('../lib/log4js')().colouredLayout;
},
'should apply level colour codes to output': function(layout) {
var output = layout({
message: "nonsense",
startTime: new Date(2010, 11, 5, 14, 18, 30, 45),
categoryName: "cheese",
level: {
colour: "green",
toString: function() { return "ERROR"; }
}
});
assert.equal(output, '\033[90m[2010-12-05 14:18:30.045] \033[39m\033[32m[ERROR] \033[39m\033[90mcheese - \033[39mnonsense');
}
}
}).export(module);