Comparing version 4.2.0 to 4.3.0
@@ -32,2 +32,5 @@ 'use strict' | ||
var autoLogging = (opts.autoLogging !== false) | ||
delete opts.autoLogging | ||
var logger = wrapChild(opts, theStream) | ||
@@ -67,4 +70,6 @@ var genReqId = reqIdGenFactory(opts.genReqId) | ||
res.on('finish', onResFinished) | ||
res.on('error', onResFinished) | ||
if (autoLogging) { | ||
res.on('finish', onResFinished) | ||
res.on('error', onResFinished) | ||
} | ||
@@ -71,0 +76,0 @@ if (next) { |
{ | ||
"name": "pino-http", | ||
"version": "4.2.0", | ||
"version": "4.3.0", | ||
"description": "High-speed HTTP logger for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "logger.js", |
@@ -100,2 +100,3 @@ # pino-http [![Build Status](https://travis-ci.org/pinojs/pino-http.svg)](https://travis-ci.org/pinojs/pino-http)[![Coverage Status](https://coveralls.io/repos/github/pinojs/pino-http/badge.svg?branch=master)](https://coveralls.io/github/pinojs/pino-http?branch=master) | ||
* `customLogLevel`: set to a `function (res, err) => { /* returns level name string */ }`. This function will be invoked to determine the level at which the log should be issued. This option is mutually exclusive with the `useLevel` option. The first argument is the HTTP response. The second argument is an error object if an error has occurred in the request. | ||
* `autoLogging`: set to `false` to disable the automatic "request completed" and "request errored" logging. Defaults to `true`. | ||
* `stream`: same as the second parameter | ||
@@ -102,0 +103,0 @@ |
28
test.js
@@ -267,2 +267,30 @@ 'use strict' | ||
test('no auto logging with autoLogging set to false', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ autoLogging: false }, dest) | ||
var timeout | ||
function handle (req, res) { | ||
logger(req, res) | ||
setTimeout(function () { | ||
res.end('hello world') | ||
}, 100) | ||
} | ||
dest.on('data', function (line) { | ||
clearTimeout(timeout) | ||
t.error(line) | ||
t.end() | ||
}) | ||
setup(t, logger, function (err, server) { | ||
t.error(err) | ||
doGet(server) | ||
timeout = setTimeout(function () { | ||
t.end() | ||
}, 200) | ||
}, handle) | ||
}) | ||
function expectResponseTime (t, dest, logger, handle) { | ||
@@ -269,0 +297,0 @@ setup(t, logger, function (err, server) { |
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
27463
616
280