New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pn-logging

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pn-logging - npm Package Compare versions

Comparing version 5.2.0 to 5.3.0

16

index.js

@@ -10,2 +10,3 @@ /*eslint no-process-env:0 no-param-reassign:0*/

var { omit, merge } = require('lodash');
var isobject = require('isobject')

@@ -129,3 +130,10 @@ var sysLogLevels;

function _logger(level) {
return function(message, meta, error) {
return function(message, meta, error, req, res) {
if (isobject(message)) {
meta = meta ? Object.assign(meta, message.meta) : message.meta;
error = error ? error : message.error;
req = req ? req : message.req;
res = res ? res : message.res;
message = message.message || message.msg;
}
var log = new this._winexConstructor({meta: this.defaultMeta});

@@ -142,2 +150,8 @@

if (req)
log.addReq(req)
if (res)
log.addRes(res)
if (error) {

@@ -144,0 +158,0 @@ this.ravenClient.captureException(error, _getSentryMeta(meta));

3

package.json
{
"name": "pn-logging",
"version": "5.2.0",
"version": "5.3.0",
"description": "A logging wrapper around winston and sentry.",

@@ -20,2 +20,3 @@ "engines": {

"deep-extend": "0.2.2",
"isobject": "3.0.1",
"lodash": "4.17.11",

@@ -22,0 +23,0 @@ "raven": "0.9.0",

@@ -100,19 +100,19 @@ /*eslint vars-on-top:0*/

it('should include default meta in log messages', function() {
log = new index.Log({
transports: [
{
TestTransport: {
level: 'debug',
__log: spy,
},
log = new index.Log({
transports: [
{
TestTransport: {
level: 'debug',
__log: spy,
},
],
sentry: {},
meta: {
type: 'server',
key1: 'value1'
}
});
},
],
sentry: {},
meta: {
type: 'server',
key1: 'value1',
},
});
log.info('msg', {key2: 'value2'})
log.info('msg', { key2: 'value2' });

@@ -130,3 +130,3 @@ sinon.assert.calledOnce(spy);

});
})
});

@@ -186,2 +186,82 @@ describe('log methods', function() {

});
it('should support req and res arguments', function() {
const req = {
headers: {
host: 'guest',
},
method: 'take',
connection: {
remoteAddress: '4.3.2.1',
},
url: 'ptth://guest/req/path?will this work',
pathname: '/req/path',
};
const res = {
statusCode: 1000000,
};
log.info('hi', { name: 'Dan' }, null, req, res);
var args = spy.args[0];
expect(args[2]).to.have.property('name', 'Dan');
expect(args[2]).to.have.property('reqHost', 'guest');
expect(args[2]).to.have.property('resStatus', '1000000');
});
it('should support opts hash', function() {
const err = new Error('zot');
const req = {
headers: {
host: 'guest',
},
method: 'take',
connection: {
remoteAddress: '4.3.2.1',
},
url: 'ptth://guest/req/path?will this work',
pathname: '/req/path',
};
const res = {
statusCode: 1000000,
};
const opts = {
message: 'hi',
meta: {
key1: 'val1',
},
error: err,
req: req,
res: res,
};
log.debug(opts);
var args = spy.args[0];
expect(args[1]).to.equal('hi');
expect(args[2]).to.have.property('key1', 'val1');
expect(args[2]).to.have.property('errMsg', 'zot');
expect(args[2]).to.have.property('reqHost', 'guest');
expect(args[2]).to.have.property('resStatus', '1000000');
});
it('should mixin or favor explicit arguments over opts hash values', function() {
const opts = {
message: 'hi',
meta: {
key1: 'val1',
},
error: null,
};
log.debug(opts, { key2: 'val2' }, new Error('zot'));
var args = spy.args[0];
expect(args[1]).to.equal('hi');
expect(args[2]).to.have.property('key1', 'val1');
expect(args[2]).to.have.property('key2', 'val2');
expect(args[2]).to.have.property('errMsg', 'zot');
});
});

@@ -188,0 +268,0 @@

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