Socket
Socket
Sign inDemoInstall

log4js-json-layout

Package Overview
Dependencies
2
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.1.0

7

lib/jsonLayout.js

@@ -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 = {};

2

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc