Comparing version 2.2.0 to 2.3.0
17
index.js
'use strict' | ||
const pino = require('pino') | ||
const stdSerializers = pino.stdSerializers | ||
const nullLogger = require('abstract-logging') | ||
@@ -17,4 +18,4 @@ | ||
options.serializers = options.serializers || {} | ||
options.serializers.req = options.serializers.req || asReqValue | ||
options.serializers.res = options.serializers.res || pino.stdSerializers.res | ||
options.serializers.req = stdSerializers.wrapRequestSerializer(options.serializers.req || stdSerializers.req) | ||
options.serializers.res = stdSerializers.wrapResponseSerializer(options.serializers.res || stdSerializers.res) | ||
options.serializers.err = options.serializers.err || pino.stdSerializers.err | ||
@@ -145,14 +146,2 @@ | ||
function asReqValue (req) { | ||
const raw = req.raw.req | ||
return { | ||
id: req.id, | ||
method: raw.method, | ||
url: raw.url, | ||
headers: raw.headers, | ||
remoteAddress: raw.connection.remoteAddress, | ||
remotePort: raw.connection.remotePort | ||
} | ||
} | ||
module.exports.register = register | ||
@@ -159,0 +148,0 @@ module.exports.register.attributes = { |
{ | ||
"name": "hapi-pino", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "Hapi plugin for the Pino logger ", | ||
@@ -34,3 +34,3 @@ "main": "index.js", | ||
"abstract-logging": "^1.0.0", | ||
"pino": "^4.10.2" | ||
"pino": "^4.15.2" | ||
}, | ||
@@ -37,0 +37,0 @@ "repository": { |
@@ -95,2 +95,10 @@ # hapi-pino [](https://travis-ci.org/pinojs/hapi-pino) [](https://coveralls.io/github/pinojs/hapi-pino?branch=master) | ||
`tags`, defaults to `'info'`. | ||
`[serializers]` - an object to overwrite the default serializers. You can but don't have to overwrite all of them. E.g. to redact the authorization header in the logs: | ||
``` | ||
{ | ||
req: require('pino-noir')(['req.headers.authorization']).req | ||
res: ... | ||
err: ... | ||
} | ||
``` | ||
- `[instance]` - uses a previously created Pino instance as the logger. | ||
@@ -97,0 +105,0 @@ The instance's `stream` and `serializers` take precedence. |
70
test.js
@@ -616,4 +616,4 @@ 'use strict' | ||
experiment('logging with overridden serializer', () => { | ||
test('with pre-defined req serializer', (done) => { | ||
experiment('custom serializers', () => { | ||
test('logging with configured req serializer', (done) => { | ||
const server = getServer() | ||
@@ -644,3 +644,3 @@ const stream = sink((data) => { | ||
test('with pre-defined res serializer', (done) => { | ||
test('logging with configured res serializer', (done) => { | ||
const server = getServer() | ||
@@ -657,3 +657,3 @@ const stream = sink((data) => { | ||
serializers: { | ||
res: (res) => ({ code: res.statusCode }) | ||
res: (res) => ({ code: res.statusCode, raw: res.raw }) | ||
} | ||
@@ -672,3 +672,3 @@ } | ||
test('with pre-defined err serializer', (done) => { | ||
test('logging with pre-defined err serializer', (done) => { | ||
const server = getServer() | ||
@@ -698,2 +698,62 @@ const stream = sink((data) => { | ||
}) | ||
test('req.raw is not enumerable', (done) => { | ||
const server = getServer() | ||
const stream = sink((data) => { | ||
expect(data.req).to.be.an.object() | ||
done() | ||
}) | ||
const logger = require('pino')(stream) | ||
const plugin = { | ||
register: Pino.register, | ||
options: { | ||
instance: logger, | ||
serializers: { | ||
req: (req) => { | ||
expect(req.raw).to.be.an.object() | ||
expect(req.propertyIsEnumerable('raw')).to.be.false() | ||
return req | ||
} | ||
} | ||
} | ||
} | ||
server.register(plugin, (err) => { | ||
expect(err).to.be.undefined() | ||
server.inject({ | ||
method: 'GET', | ||
url: '/' | ||
}) | ||
}) | ||
}) | ||
test('res.raw is not enumerable', (done) => { | ||
const server = getServer() | ||
const stream = sink((data) => { | ||
expect(data.res).to.be.an.object() | ||
done() | ||
}) | ||
const logger = require('pino')(stream) | ||
const plugin = { | ||
register: Pino.register, | ||
options: { | ||
instance: logger, | ||
serializers: { | ||
res: (res) => { | ||
expect(res.raw).to.be.an.object() | ||
expect(res.propertyIsEnumerable('raw')).to.be.false() | ||
return res | ||
} | ||
} | ||
} | ||
} | ||
server.register(plugin, (err) => { | ||
expect(err).to.be.undefined() | ||
server.inject({ | ||
method: 'GET', | ||
url: '/' | ||
}) | ||
}) | ||
}) | ||
}) | ||
@@ -700,0 +760,0 @@ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
35683
1132
164
1
Updatedpino@^4.15.2