Comparing version 10.1.0 to 10.2.0
@@ -42,2 +42,3 @@ // Project: https://github.com/pinojs/pino-http#readme | ||
quietReqLogger?: boolean | undefined; | ||
quietResLogger?: boolean | undefined; | ||
} | ||
@@ -44,0 +45,0 @@ |
@@ -158,2 +158,3 @@ | ||
quietReqLogger: canBeUndefined(rtnBool()), | ||
quietResLogger: canBeUndefined(rtnBool()), | ||
} | ||
@@ -160,0 +161,0 @@ |
@@ -45,3 +45,3 @@ 'use strict' | ||
if (level && typeof level === 'string') { | ||
const logLevel = level.trim().toLowerCase() | ||
const logLevel = level.trim() | ||
if (validLogLevels.includes(logLevel) === true) { | ||
@@ -81,2 +81,3 @@ return logLevel | ||
const quietReqLogger = !!opts.quietReqLogger | ||
const quietResLogger = !!opts.quietResLogger | ||
@@ -152,3 +153,3 @@ const logger = wrapChild(opts, theStream) | ||
const responseLogger = fullReqLogger | ||
const responseLogger = quietResLogger ? log : fullReqLogger | ||
const requestLogger = quietReqLogger ? log : fullReqLogger | ||
@@ -155,0 +156,0 @@ |
{ | ||
"name": "pino-http", | ||
"version": "10.1.0", | ||
"version": "10.2.0", | ||
"description": "High-speed HTTP logger for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "logger.js", |
@@ -113,2 +113,3 @@ # pino-http [![Build Status](https://img.shields.io/github/actions/workflow/status/pinojs/pino-http/ci.yml?branch=master)](https://github.com/pinojs/pino-http/actions) | ||
* `quietReqLogger`: when `true`, the child logger available on `req.log` will no longer contain the full bindings and will now only have the request id bound at `reqId` (note: the autoLogging messages and the logger available on `res.log` will remain the same except they will also have the additional `reqId` property). default: `false` | ||
* `quietResLogger`: when `true`, the child logger available on `res.log` will no longer contain the full bindings and will now only have the request id bound at `reqId` (note: the autoLogging message sent on request completion will only contain `req`). default: `false` | ||
@@ -115,0 +116,0 @@ `stream`: the destination stream. Could be passed in as an option too. |
@@ -226,6 +226,6 @@ 'use strict' | ||
customLevels: { | ||
custom: 25 | ||
infoCustom: 25 | ||
}, | ||
useLevel: 'custom', | ||
level: 'custom' | ||
useLevel: 'infoCustom', | ||
level: 'infoCustom' | ||
}, | ||
@@ -1468,1 +1468,58 @@ dest | ||
}) | ||
test('quiet response logging', function (t) { | ||
t.plan(5) | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ quietResLogger: true }, dest) | ||
function handler (req, res) { | ||
t.pass('called') | ||
req.id = 'testId' | ||
logger(req, res) | ||
req.log.info('quiet message') | ||
res.end('hello world') | ||
} | ||
setup(t, logger, function (err, server) { | ||
t.error(err) | ||
doGet(server, null, function () { | ||
dest.read() | ||
const responseLine = dest.read() | ||
t.equal(responseLine.msg, DEFAULT_REQUEST_COMPLETED_MSG) | ||
t.notOk(responseLine.req) | ||
t.ok(responseLine.res) | ||
t.end() | ||
}) | ||
}, handler) | ||
}) | ||
test('quiet request and response logging', function (t) { | ||
t.plan(6) | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ quietReqLogger: true, quietResLogger: true }, dest) | ||
function handler (req, res) { | ||
t.pass('called') | ||
req.id = 'testId' | ||
logger(req, res) | ||
req.log.info('quiet message') | ||
res.end('hello world') | ||
} | ||
setup(t, logger, function (err, server) { | ||
t.error(err) | ||
doGet(server, null, function () { | ||
dest.read() | ||
const responseLine = dest.read() | ||
t.equal(responseLine.msg, DEFAULT_REQUEST_COMPLETED_MSG) | ||
t.equal(responseLine.reqId, 'testId') | ||
t.notOk(responseLine.req) | ||
t.ok(responseLine.res) | ||
t.end() | ||
}) | ||
}, handler) | ||
}) |
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
82221
1946
478