Comparing version 1.3.0 to 1.3.1
@@ -70,2 +70,3 @@ 'use strict' | ||
var prevLogger = opts.logger | ||
var prevGenReqId = opts.genReqId | ||
var logger = null | ||
@@ -75,4 +76,6 @@ | ||
opts.logger = undefined | ||
opts.genReqId = undefined | ||
logger = prevLogger.child(opts) | ||
opts.logger = prevLogger | ||
opts.genReqId = prevGenReqId | ||
} else { | ||
@@ -79,0 +82,0 @@ logger = pino(opts, stream) |
{ | ||
"name": "pino-http", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "High-speed HTTP logger for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "logger.js", |
31
test.js
@@ -194,1 +194,32 @@ 'use strict' | ||
}) | ||
test('support a custom instance with custom genReqId function', function (t) { | ||
var dest = split(JSON.parse) | ||
var idToTest | ||
function genReqId (req) { | ||
t.ok(req.url, 'The first argument must be the request parameter') | ||
idToTest = (Date.now() + Math.random()).toString(32) | ||
return idToTest | ||
} | ||
var logger = pinoHttp({ | ||
logger: pino(dest), | ||
genReqId: genReqId | ||
}) | ||
setup(t, logger, function (err, server) { | ||
t.error(err) | ||
doGet(server) | ||
}) | ||
dest.on('data', function (line) { | ||
t.ok(line.req, 'req is defined') | ||
t.ok(line.res, 'res is defined') | ||
t.notOk(line.genReqId) | ||
t.equal(line.msg, 'request completed', 'message is set') | ||
t.equal(line.req.method, 'GET', 'method is get') | ||
t.equal(line.res.statusCode, 200, 'statusCode is 200') | ||
t.end() | ||
}) | ||
}) |
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
16140
338