log4js-json-layout
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -5,3 +5,22 @@ /** | ||
'use strict'; | ||
var util = require('util'); | ||
function wrapErrorsWithInspect(items) { | ||
return items.map(function (item) { | ||
if ((item instanceof Error) && item.stack) { | ||
return { | ||
inspect: function () { | ||
return util.format(item) + '\n' + item.stack; | ||
} | ||
}; | ||
} else { | ||
return item; | ||
} | ||
}); | ||
} | ||
function formatLogData(logData) { | ||
var data = Array.isArray(logData) ? logData : Array.prototype.slice.call(arguments); | ||
return util.format.apply(util, wrapErrorsWithInspect(data)); | ||
} | ||
function jsonLayout(config) { | ||
@@ -20,3 +39,5 @@ function formatter(data) { | ||
} | ||
if (output.data) { | ||
output.data = formatLogData(output.data); | ||
} | ||
if (config.include && config.include.length) { | ||
@@ -23,0 +44,0 @@ var newOutput = {}; |
{ | ||
"name": "log4js-json-layout", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "provides a slim and easy to use json-layout for log4js-node", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# log4js-json-layout | ||
[![NPM](https://nodei.co/npm/log4js-json-layout.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/log4js-json-layouts/) | ||
[![NPM](https://nodei.co/npm/log4js-json-layout.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/log4js-json-layout/) | ||
@@ -16,2 +16,3 @@ provides a slim and easy to use json-layout for log4js-node (https://github.com/nomiddlename/log4js-node) | ||
log object will contain these properties : ["startTime","categoryName","data","level"] | ||
source param will be added to each json object if provided | ||
@@ -28,2 +29,3 @@ ``` | ||
type: 'json', | ||
source : 'development', | ||
include: ['startTime', 'categoryName'] | ||
@@ -30,0 +32,0 @@ } |
@@ -46,3 +46,8 @@ /** | ||
output.should.be.deep.equal(JSON.stringify({level: expected.level, data: expected.data})); | ||
}) | ||
}); | ||
it('should format data', function () { | ||
data.data = ['%s', 'aaa']; | ||
var output = layout({})(data); | ||
JSON.parse(output).data.should.equal('aaa'); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34790
108
35