log4js-json-layout
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -65,2 +65,7 @@ const util = require('util'); | ||
// Emit own properties of config.static if specified | ||
if (_.has(config, 'static')) { | ||
Object.assign(output, config.static); | ||
} | ||
const messages = _.isArray(data.data) ? data.data : [data.data]; | ||
@@ -83,2 +88,4 @@ | ||
// Only include fields specified in 'include' field | ||
// if field is specified | ||
if (config.include && config.include.length) { | ||
@@ -85,0 +92,0 @@ const newOutput = {}; |
{ | ||
"name": "log4js-json-layout", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Provides a slim and easy to use json-layout for log4js-node", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -33,4 +33,6 @@ # log4js-json-layout | ||
- `level` - level in human readable format | ||
- `source` - if provided, will be included | ||
- `source` - if provided, will be included | ||
Additional properties can be specified as extra arguments of object type during invocation of log function. Static or constant properties can be specified using the `static` config option. | ||
### Options | ||
@@ -41,3 +43,4 @@ | ||
- `include` - array of properties to include in the log object | ||
- `colors` - boolean; off by default. If set to true, colorizes the output using log4js default color scheme based on log level. Useful for development, do not use for storing logs. | ||
- `colors` - boolean; off by default. If set to true, colorizes the output using log4js default color scheme based on log level. Useful for development, do not use for storing logs | ||
- `static` - object, name value pairs of this object are added to output | ||
@@ -73,2 +76,5 @@ ### Example Config | ||
source: 'development', | ||
static: { | ||
appName: 'mysuperbapp' | ||
}, | ||
include: ['startTime', 'categoryName'], | ||
@@ -75,0 +81,0 @@ } |
@@ -149,2 +149,21 @@ const _ = require('lodash'); | ||
}); | ||
it('should add static fields when configured', function () { | ||
data.data = [{ id: 123, data: 'aaa' }]; | ||
const actual = JSON.parse(layout({ | ||
static: { appName: 'testapp', source: 'development' } | ||
})(data)); | ||
actual.id.should.equal(123); | ||
actual.data.should.equal('aaa'); | ||
actual.appName.should.equal('testapp'); | ||
actual.source.should.equal('development'); | ||
}); | ||
it('should still pick specific keys when static fields are configured', function () { | ||
const actual = layout({ | ||
static: { appName: 'testapp' }, | ||
include: ['level', 'data'], | ||
})(data); | ||
actual.should.deep.equal(JSON.stringify({ level: expected.level, data: expected.data })); | ||
}); | ||
}); |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
66569
268
82
0