From 9a34d9edfd5cc62cc60bbe3beaf5d01f9601b5d1 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Thu, 15 Sep 2011 08:18:24 +1000 Subject: [PATCH] fixed missing space between log data elements --- lib/layouts.js | 3 +++ test/layouts.js | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/layouts.js b/lib/layouts.js index 3d58695..0e688fe 100644 --- a/lib/layouts.js +++ b/lib/layouts.js @@ -44,6 +44,9 @@ function formatLogData(logData) { } data.forEach(function (item) { + if (output) { + output += ' '; + } if (item && item.stack) { output += item.stack; } else { diff --git a/test/layouts.js b/test/layouts.js index 2a3b55c..5826fa3 100644 --- a/test/layouts.js +++ b/test/layouts.js @@ -57,14 +57,14 @@ vows.describe('log4js layouts').addBatch({ }, 'should support the console.log format for the message' : function(layout) { assert.equal(layout({ - data: ["thing %d", 1] + data: ["thing %d", 1, "cheese"] , startTime: new Date(2010, 11, 5, 14, 18, 30, 45) , categoryName: "cheese" , level : { colour: "green" , toString: function() { return "ERROR"; } } - }), "thing 1"); + }), "thing 1 'cheese'"); }, 'should output the first item even if it is not a string': function(layout) { assert.equal(layout({ @@ -102,7 +102,7 @@ vows.describe('log4js layouts').addBatch({ error = new Error("Some made-up error"), stack = error.stack.split(/\n/); - event.data = ['this is a test ', error]; + event.data = ['this is a test', error]; output = layout(event); lines = output.split(/\n/); @@ -114,7 +114,7 @@ vows.describe('log4js layouts').addBatch({ }, 'should output any extra data in the log event as util.inspect strings': function(args) { var layout = args[0], event = args[1], output, lines; - event.data = ['this is a test ', { + event.data = ['this is a test', { name: 'Cheese', message: 'Gorgonzola smells.' }];