Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gelf-pro

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gelf-pro - npm Package Compare versions

Comparing version 0.9.0 to 0.9.1

6

lib/gelf-pro.js

@@ -23,2 +23,3 @@ /**

broadcast: [],
transform: [],
adapterName: 'udp',

@@ -168,2 +169,7 @@ adapterOptions: {

// transforming
if (this.config.transform.length) {
_.invokeMap(this.config.transform, _.call, null, extra);
}
// broadcasting

@@ -170,0 +176,0 @@ if (this.config.broadcast.length) {

6

package.json
{
"name": "gelf-pro",
"version": "0.9.0",
"version": "0.9.1",
"main": "./lib/gelf-pro.js",

@@ -20,3 +20,3 @@ "author": "Kanstantsin Kamkou <kkamkou@gmail.com>",

"dependencies": {
"lodash": "~4.16",
"lodash": "~4.16.4",
"async": "~2.0"

@@ -27,3 +27,3 @@ },

"should": "~11.1",
"mocha": "~3.0.0-1",
"mocha": "~3.1.0",
"mocha-lcov-reporter": "~1.2.0",

@@ -30,0 +30,0 @@ "coveralls": "~2.11",

@@ -32,2 +32,3 @@ node-gelf pro

filter: [], // optional; filters to discard a message
transform: [], // optional; transformers for a message
broadcast: [], // optional; listeners of a message

@@ -75,5 +76,4 @@ levels: {}, // optional; default: see the levels section below

##### Filtering
Sometimes we have to discard a message which is not suitable for the current environment.
Sometimes we have to discard a message which is not suitable for the current environment. It is `NOT` possible to modify the data.
```javascript
// it is not possible to modify the data.
log.setConfig({

@@ -88,7 +88,22 @@ filter: [

##### Transforming
`transforming` happens after `filtering`. It is possible to modify the data.
```javascript
log.setConfig({
transform: [
function (message) { // unwind an error
if (_.isError(message.error)) {
message.error = {message: message.error.message, stack: message.error.stack};
}
return message;
}
]
});
```
##### Broadcasting
`broadcasting` happens after `filtering`.
`broadcasting` happens after `transforming`. It is `NOT` possible to modify the data.
```javascript
// it is not possible to modify the data.
log.setConfig({

@@ -95,0 +110,0 @@ broadcast: [

@@ -185,2 +185,33 @@ 'use strict';

'Transform messages': function () {
var gelf = _.cloneDeep(gelfOriginal),
err = new Error('E!'),
expected = {
short_message: 'expected',
level: 6,
_world: 'hello',
_error_message: err.message,
_error_stack: err.stack
},
transform1 = function (extra) {
return _.merge(
extra,
{short_message: expected.short_message, level: expected.level, world: expected._world}
);
},
transform2 = function (extra) {
if (_.isError(extra.error)) {
extra.error = {message: extra.error.message, stack: extra.error.stack};
}
return extra;
};
sinon.spy(gelf, 'getStringFromObject');
gelf.setConfig({transform: [transform1, transform2]});
gelf.notice('original', {world: false, error: err});
JSON.parse(gelf.getStringFromObject.lastCall.returnValue).should.containEql(expected);
},
'Broadcast messages': function () {

@@ -187,0 +218,0 @@ var expected = [{short_message: 'test', level: 6, world: true}],

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc