fixed a bug where if the first log arg was not a string it wouldn't get logged

This commit is contained in:
Gareth Jones 2011-07-22 12:28:02 +10:00
parent ec21ec63f0
commit 4b32456db7
2 changed files with 16 additions and 1 deletions

View File

@ -41,6 +41,9 @@ function formatLogData(logData) {
if (data.length > 0) {
output += '\n';
}
} else {
//put it back, it's not a format string
data.unshift(format);
}
data.forEach(function (item) {

View File

@ -65,7 +65,19 @@ vows.describe('log4js layouts').addBatch({
, toString: function() { return "ERROR"; }
}
}), "thing 1");
}
},
'should output the first item even if it is not a string': function(layout) {
assert.equal(layout({
data: [ { thing: 1} ]
, startTime: new Date(2010, 11, 5, 14, 18, 30, 45)
, categoryName: "cheese"
, level: {
colour: "green"
, toString: function() { return "ERROR"; }
}
}), "{ thing: 1 }");
}
},
'basicLayout': {