Comparing version 5.8.0 to 6.0.0
'use strict' | ||
var http = require('http') | ||
var httpNdjson = require('http-ndjson') | ||
var server = http.createServer(handle) | ||
const http = require('http') | ||
const httpNdjson = require('http-ndjson') | ||
const server = http.createServer(handle) | ||
var pid = process.pid | ||
var hostname = require('os').hostname() | ||
const pid = process.pid | ||
const hostname = require('os').hostname() | ||
function handle (req, res) { | ||
res.end('hello world') | ||
var opts = { | ||
const opts = { | ||
pid: pid, | ||
@@ -14,0 +14,0 @@ hostname: hostname, |
'use strict' | ||
var http = require('http') | ||
var httpNdjson = require('http-ndjson') | ||
var server = http.createServer(handle) | ||
const http = require('http') | ||
const httpNdjson = require('http-ndjson') | ||
const server = http.createServer(handle) | ||
@@ -7,0 +7,0 @@ function handle (req, res) { |
'use strict' | ||
var http = require('http') | ||
var server = http.createServer(handle) | ||
const http = require('http') | ||
const server = http.createServer(handle) | ||
@@ -6,0 +6,0 @@ function handle (req, res) { |
'use strict' | ||
var http = require('http') | ||
var server = http.createServer(handle) | ||
const http = require('http') | ||
const server = http.createServer(handle) | ||
var logger = require('../')({ | ||
const logger = require('../')({ | ||
extreme: true | ||
@@ -8,0 +8,0 @@ }) |
'use strict' | ||
var http = require('http') | ||
var server = http.createServer(handle) | ||
const http = require('http') | ||
const server = http.createServer(handle) | ||
var logger = require('../')() | ||
const logger = require('../')() | ||
@@ -8,0 +8,0 @@ function handle (req, res) { |
'use strict' | ||
var http = require('http') | ||
var server = http.createServer(handle) | ||
const http = require('http') | ||
const server = http.createServer(handle) | ||
var logger = require('./')() | ||
const logger = require('./')() | ||
@@ -8,0 +8,0 @@ function handle (req, res) { |
'use strict' | ||
var pino = require('pino') | ||
var serializers = require('pino-std-serializers') | ||
var URL = require('fast-url-parser') | ||
var startTime = Symbol('startTime') | ||
const pino = require('pino') | ||
const serializers = require('pino-std-serializers') | ||
const getCallerFile = require('get-caller-file') | ||
const URL = require('fast-url-parser') | ||
const startTime = Symbol('startTime') | ||
@@ -17,10 +18,10 @@ function pinoLogger (opts, stream) { | ||
opts.customAttributeKeys = opts.customAttributeKeys || {} | ||
var reqKey = opts.customAttributeKeys.req || 'req' | ||
var resKey = opts.customAttributeKeys.res || 'res' | ||
var errKey = opts.customAttributeKeys.err || 'err' | ||
var requestIdKey = opts.customAttributeKeys.reqId || 'reqId' | ||
var responseTimeKey = opts.customAttributeKeys.responseTime || 'responseTime' | ||
const reqKey = opts.customAttributeKeys.req || 'req' | ||
const resKey = opts.customAttributeKeys.res || 'res' | ||
const errKey = opts.customAttributeKeys.err || 'err' | ||
const requestIdKey = opts.customAttributeKeys.reqId || 'reqId' | ||
const responseTimeKey = opts.customAttributeKeys.responseTime || 'responseTime' | ||
delete opts.customAttributeKeys | ||
var customProps = opts.customProps || opts.reqCustomProps || {} | ||
const customProps = opts.customProps || opts.reqCustomProps || {} | ||
@@ -30,5 +31,5 @@ opts.wrapSerializers = 'wrapSerializers' in opts ? opts.wrapSerializers : true | ||
opts.serializers = Object.assign({}, opts.serializers) | ||
var requestSerializer = opts.serializers[reqKey] || opts.serializers.req || serializers.req | ||
var responseSerializer = opts.serializers[resKey] || opts.serializers.res || serializers.res | ||
var errorSerializer = opts.serializers[errKey] || opts.serializers.err || serializers.err | ||
const requestSerializer = opts.serializers[reqKey] || opts.serializers.req || serializers.req | ||
const responseSerializer = opts.serializers[resKey] || opts.serializers.res || serializers.res | ||
const errorSerializer = opts.serializers[errKey] || opts.serializers.err || serializers.err | ||
opts.serializers[reqKey] = serializers.wrapRequestSerializer(requestSerializer) | ||
@@ -44,25 +45,25 @@ opts.serializers[resKey] = serializers.wrapResponseSerializer(responseSerializer) | ||
var useLevel = opts.useLevel || 'info' | ||
var customLogLevel = opts.customLogLevel | ||
const useLevel = opts.useLevel || 'info' | ||
const customLogLevel = opts.customLogLevel | ||
delete opts.useLevel | ||
delete opts.customLogLevel | ||
var theStream = opts.stream || stream | ||
const theStream = opts.stream || stream | ||
delete opts.stream | ||
var autoLogging = (opts.autoLogging !== false) | ||
var autoLoggingIgnore = opts.autoLogging && opts.autoLogging.ignore ? opts.autoLogging.ignore : null | ||
var autoLoggingIgnorePaths = (opts.autoLogging && opts.autoLogging.ignorePaths) ? opts.autoLogging.ignorePaths : [] | ||
var autoLoggingGetPath = opts.autoLogging && opts.autoLogging.getPath ? opts.autoLogging.getPath : null | ||
const autoLogging = (opts.autoLogging !== false) | ||
const autoLoggingIgnore = opts.autoLogging && opts.autoLogging.ignore ? opts.autoLogging.ignore : null | ||
const autoLoggingIgnorePaths = (opts.autoLogging && opts.autoLogging.ignorePaths) ? opts.autoLogging.ignorePaths : [] | ||
const autoLoggingGetPath = opts.autoLogging && opts.autoLogging.getPath ? opts.autoLogging.getPath : null | ||
delete opts.autoLogging | ||
var successMessage = opts.customSuccessMessage || function () { return 'request completed' } | ||
var errorMessage = opts.customErrorMessage || function () { return 'request errored' } | ||
const successMessage = opts.customSuccessMessage || function () { return 'request completed' } | ||
const errorMessage = opts.customErrorMessage || function () { return 'request errored' } | ||
delete opts.customSuccessfulMessage | ||
delete opts.customErroredMessage | ||
var quietReqLogger = !!opts.quietReqLogger | ||
const quietReqLogger = !!opts.quietReqLogger | ||
var logger = wrapChild(opts, theStream) | ||
var genReqId = reqIdGenFactory(opts.genReqId) | ||
const logger = wrapChild(opts, theStream) | ||
const genReqId = reqIdGenFactory(opts.genReqId) | ||
loggingMiddleware.logger = logger | ||
@@ -75,8 +76,8 @@ return loggingMiddleware | ||
var log = this.log | ||
var responseTime = Date.now() - this[startTime] | ||
var level = customLogLevel ? customLogLevel(this, err) : useLevel | ||
const log = this.log | ||
const responseTime = Date.now() - this[startTime] | ||
const level = customLogLevel ? customLogLevel(this, err) : useLevel | ||
if (err || this.err || this.statusCode >= 500) { | ||
var error = err || this.err || new Error('failed with status code ' + this.statusCode) | ||
const error = err || this.err || new Error('failed with status code ' + this.statusCode) | ||
@@ -98,10 +99,10 @@ log[level]({ | ||
function loggingMiddleware (req, res, next) { | ||
var shouldLogSuccess = true | ||
let shouldLogSuccess = true | ||
req.id = genReqId(req) | ||
var log = quietReqLogger ? logger.child({ [requestIdKey]: req.id }) : logger | ||
const log = quietReqLogger ? logger.child({ [requestIdKey]: req.id }) : logger | ||
var fullReqLogger = log.child({ [reqKey]: req }) | ||
var customPropBindings = (typeof customProps === 'function') ? customProps(req, res) : customProps | ||
let fullReqLogger = log.child({ [reqKey]: req }) | ||
const customPropBindings = (typeof customProps === 'function') ? customProps(req, res) : customProps | ||
fullReqLogger = fullReqLogger.child(customPropBindings) | ||
@@ -116,3 +117,3 @@ | ||
if (autoLoggingIgnorePaths.length) { | ||
var url | ||
let url | ||
if (autoLoggingGetPath) { | ||
@@ -154,5 +155,5 @@ url = URL.parse(autoLoggingGetPath(req)) | ||
function wrapChild (opts, stream) { | ||
var prevLogger = opts.logger | ||
var prevGenReqId = opts.genReqId | ||
var logger = null | ||
const prevLogger = opts.logger | ||
const prevGenReqId = opts.genReqId | ||
let logger = null | ||
@@ -166,2 +167,6 @@ if (prevLogger) { | ||
} else { | ||
if (opts.transport && !opts.transport.caller) { | ||
opts.transport.caller = getCallerFile() | ||
} | ||
logger = pino(opts, stream) | ||
@@ -175,4 +180,4 @@ } | ||
if (typeof func === 'function') return func | ||
var maxInt = 2147483647 | ||
var nextReqId = 0 | ||
const maxInt = 2147483647 | ||
let nextReqId = 0 | ||
return function genReqId (req) { | ||
@@ -179,0 +184,0 @@ return req.id || (nextReqId = (nextReqId + 1) & maxInt) |
{ | ||
"name": "pino-http", | ||
"version": "5.8.0", | ||
"version": "6.0.0", | ||
"description": "High-speed HTTP logger for Node.js", | ||
@@ -8,3 +8,4 @@ "main": "logger.js", | ||
"fast-url-parser": "^1.1.3", | ||
"pino": "^6.13.0", | ||
"get-caller-file": "^2.0.5", | ||
"pino": "^7.0.5", | ||
"pino-std-serializers": "^4.0.0" | ||
@@ -17,3 +18,3 @@ }, | ||
"pre-commit": "^1.1.2", | ||
"split2": "^3.0.0", | ||
"split2": "^4.0.0", | ||
"standard": "^16.0.3", | ||
@@ -20,0 +21,0 @@ "tap": "^15.0.0" |
@@ -41,6 +41,6 @@ # pino-http [![Build Status](https://img.shields.io/github/workflow/status/pinojs/pino-http/CI)](https://github.com/pinojs/pino-http/actions) | ||
var http = require('http') | ||
var server = http.createServer(handle) | ||
const http = require('http') | ||
const server = http.createServer(handle) | ||
var logger = require('pino-http')() | ||
const logger = require('pino-http')() | ||
@@ -122,6 +122,6 @@ function handle (req, res) { | ||
var http = require('http') | ||
var server = http.createServer(handle) | ||
var pino = require('pino') | ||
var logger = require('pino-http')({ | ||
const http = require('http') | ||
const server = http.createServer(handle) | ||
const pino = require('pino') | ||
const logger = require('pino-http')({ | ||
// Reuse an existing logger instance | ||
@@ -203,3 +203,3 @@ logger: pino(), | ||
```js | ||
var pinoHttp = require('pinoHttp')(); | ||
const pinoHttp = require('pinoHttp')(); | ||
pinoHttp.logger.level = 'silent'; | ||
@@ -218,5 +218,5 @@ ``` | ||
```js | ||
var http = require('http') | ||
var logger = require('pino-http')() | ||
var someImportantThingThatHasToBeFirst = require('some-important-thing') | ||
const http = require('http') | ||
const logger = require('pino-http')() | ||
const someImportantThingThatHasToBeFirst = require('some-important-thing') | ||
http.createServer((req, res) => { | ||
@@ -292,3 +292,3 @@ res[logger.startTime] = Date.now() | ||
```js | ||
var logger = require('pino-http')({ | ||
const logger = require('pino-http')({ | ||
serializers: { | ||
@@ -312,3 +312,3 @@ req (req) { | ||
```js | ||
var logger = require('pino-http')({ | ||
const logger = require('pino-http')({ | ||
wrapSerializers: false, | ||
@@ -315,0 +315,0 @@ serializers: { |
231
test.js
'use strict' | ||
var test = require('tap').test | ||
var http = require('http') | ||
var pinoHttp = require('./') | ||
var pino = require('pino') | ||
var split = require('split2') | ||
const test = require('tap').test | ||
const http = require('http') | ||
const pinoHttp = require('./') | ||
const pino = require('pino') | ||
const split = require('split2') | ||
const { join } = require('path') | ||
var ERROR_URL = '/make-error' | ||
var noop = function () {} | ||
const ERROR_URL = '/make-error' | ||
const noop = function () {} | ||
function setup (t, logger, cb, handler, next) { | ||
var server = http.createServer(handler || function (req, res) { | ||
const server = http.createServer(handler || function (req, res) { | ||
logger(req, res, next) | ||
@@ -39,4 +40,4 @@ if (req.url === '/') { | ||
path = path || '/' | ||
var address = server.address() | ||
var cb = callback || noop | ||
const address = server.address() | ||
const cb = callback || noop | ||
return http.get('http://' + address.address + ':' + address.port + path, cb) | ||
@@ -46,4 +47,4 @@ } | ||
test('default settings', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp(dest) | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp(dest) | ||
@@ -66,4 +67,4 @@ setup(t, logger, function (err, server) { | ||
test('stream in options', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ stream: dest }) | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ stream: dest }) | ||
@@ -85,7 +86,23 @@ setup(t, logger, function (err, server) { | ||
test('add transport.caller information when missing', function (t) { | ||
t.plan(1) | ||
const options = { | ||
transport: { | ||
targets: [ | ||
{ target: 'pino/file', options: { destination: '/dev/null' } } | ||
] | ||
} | ||
} | ||
const logger = pinoHttp(options) | ||
logger.logger.info('hello world') | ||
t.equal(options.transport.caller, join(__dirname, 'logger.js'), 'caller is set') | ||
}) | ||
test('exposes the internal pino', function (t) { | ||
t.plan(1) | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp(dest) | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp(dest) | ||
@@ -100,4 +117,4 @@ dest.on('data', function (line) { | ||
test('uses the log level passed in as an option', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ useLevel: 'debug', level: 'debug' }, dest) | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ useLevel: 'debug', level: 'debug' }, dest) | ||
@@ -117,4 +134,4 @@ setup(t, logger, function (err, server) { | ||
test('uses the custom log level passed in as an option', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ | ||
customLogLevel: function (res, err) { | ||
@@ -138,4 +155,4 @@ return 'warn' | ||
test('throw error if custom log level and log level passed in together', function (t) { | ||
var dest = split(JSON.parse) | ||
var throwFunction = function () { | ||
const dest = split(JSON.parse) | ||
const throwFunction = function () { | ||
pinoHttp({ | ||
@@ -155,5 +172,5 @@ useLevel: 'info', | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp(dest) | ||
var lastId = null | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp(dest) | ||
let lastId = null | ||
@@ -176,4 +193,4 @@ setup(t, logger, function (err, server) { | ||
var dest = split(JSON.parse) | ||
var idToTest | ||
const dest = split(JSON.parse) | ||
let idToTest | ||
function genReqId (req) { | ||
@@ -185,3 +202,3 @@ t.ok(req.url, 'The first argument must be the request parameter') | ||
var logger = pinoHttp({ genReqId: genReqId }, dest) | ||
const logger = pinoHttp({ genReqId: genReqId }, dest) | ||
setup(t, logger, function (err, server) { | ||
@@ -201,5 +218,5 @@ t.error(err) | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp(dest) | ||
var someId = 'id-to-reuse-12345' | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp(dest) | ||
const someId = 'id-to-reuse-12345' | ||
@@ -222,5 +239,5 @@ function loggerWithExistingReqId (req, res) { | ||
test('startTime', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp(dest) | ||
var someStartTime = 56 | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp(dest) | ||
const someStartTime = 56 | ||
@@ -247,4 +264,4 @@ t.equal(typeof pinoHttp.startTime, 'symbol') | ||
test('responseTime', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp(dest) | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp(dest) | ||
@@ -263,4 +280,4 @@ setup(t, logger, function (err, server) { | ||
test('responseTime for errored request', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp(dest) | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp(dest) | ||
@@ -280,4 +297,4 @@ setup(t, logger, function (err, server) { | ||
test('responseTime for request emitting error event', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp(dest) | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp(dest) | ||
@@ -302,4 +319,4 @@ function handle (req, res) { | ||
test('no auto logging with autoLogging set to false', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ autoLogging: false }, dest) | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ autoLogging: false }, dest) | ||
@@ -309,3 +326,3 @@ setup(t, logger, function (err, server) { | ||
doGet(server, null, function () { | ||
var line = dest.read() | ||
const line = dest.read() | ||
t.equal(line, null) | ||
@@ -318,4 +335,4 @@ t.end() | ||
test('no auto logging with autoLogging set to true and path ignored', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ | ||
autoLogging: { | ||
@@ -329,3 +346,3 @@ ignorePaths: ['/ignorethis'] | ||
doGet(server, '/ignorethis', function () { | ||
var line = dest.read() | ||
const line = dest.read() | ||
t.equal(line, null) | ||
@@ -338,4 +355,4 @@ t.end() | ||
test('auto logging with autoLogging set to true and path not ignored', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ | ||
autoLogging: { | ||
@@ -358,4 +375,4 @@ ignorePaths: ['/ignorethis'] | ||
test('no auto logging with autoLogging set to true and getPath result is ignored', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ | ||
autoLogging: { | ||
@@ -372,3 +389,3 @@ ignorePaths: ['/ignorethis'], | ||
doGet(server, '/ignorethis', function () { | ||
var line = dest.read() | ||
const line = dest.read() | ||
t.equal(line, null) | ||
@@ -381,4 +398,4 @@ t.end() | ||
test('auto logging with autoLogging set to true and getPath result is not ignored', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ | ||
autoLogging: { | ||
@@ -404,4 +421,4 @@ ignorePaths: ['/ignorethis'], | ||
test('no auto logging with autoLogging set to use regular expressions. result is ignored', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ | ||
autoLogging: { | ||
@@ -457,4 +474,4 @@ ignorePaths: [/\/[A-z]{4}\/ignorethis/, '/another-ignored-path'], | ||
test('support a custom instance', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ | ||
logger: pino(dest) | ||
@@ -479,5 +496,5 @@ }) | ||
test('support a custom instance with custom genReqId function', function (t) { | ||
var dest = split(JSON.parse) | ||
const dest = split(JSON.parse) | ||
var idToTest | ||
let idToTest | ||
function genReqId (req) { | ||
@@ -489,3 +506,3 @@ t.ok(req.url, 'The first argument must be the request parameter') | ||
var logger = pinoHttp({ | ||
const logger = pinoHttp({ | ||
logger: pino(dest), | ||
@@ -512,4 +529,4 @@ genReqId: genReqId | ||
test('does not crash when no request connection object', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ | ||
logger: pino(dest) | ||
@@ -519,3 +536,3 @@ }) | ||
var server = http.createServer(handler) | ||
const server = http.createServer(handler) | ||
server.unref() | ||
@@ -537,4 +554,4 @@ server.listen(9999, () => { | ||
test('does not return excessively long object', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ | ||
logger: pino(dest), | ||
@@ -550,3 +567,3 @@ serializers: { | ||
var server = http.createServer(handler) | ||
const server = http.createServer(handler) | ||
server.unref() | ||
@@ -593,4 +610,4 @@ server.listen(0, () => { | ||
t.plan(2) | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ | ||
logger: pino(dest), | ||
@@ -606,3 +623,3 @@ serializers: { | ||
var server = http.createServer(handler) | ||
const server = http.createServer(handler) | ||
server.unref() | ||
@@ -621,4 +638,4 @@ server.listen(0, () => { | ||
t.plan(2) | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ | ||
logger: pino(dest), | ||
@@ -634,3 +651,3 @@ serializers: { | ||
var server = http.createServer(handler) | ||
const server = http.createServer(handler) | ||
server.unref() | ||
@@ -649,4 +666,4 @@ server.listen(0, () => { | ||
t.plan(1) | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ | ||
logger: pino(dest), | ||
@@ -661,3 +678,3 @@ serializers: { | ||
var server = http.createServer(handler) | ||
const server = http.createServer(handler) | ||
server.unref() | ||
@@ -715,4 +732,4 @@ server.listen(0, () => { | ||
t.plan(1) | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ | ||
logger: pino(dest), | ||
@@ -727,3 +744,3 @@ serializers: { | ||
var server = http.createServer(handler) | ||
const server = http.createServer(handler) | ||
server.unref() | ||
@@ -741,5 +758,5 @@ server.listen(0, () => { | ||
test('uses the custom successMessage callback if passed in as an option', function (t) { | ||
var dest = split(JSON.parse) | ||
var customResponseMessage = 'Custom response message' | ||
var logger = pinoHttp({ | ||
const dest = split(JSON.parse) | ||
const customResponseMessage = 'Custom response message' | ||
const logger = pinoHttp({ | ||
customSuccessMessage: function (res) { | ||
@@ -762,5 +779,5 @@ return customResponseMessage | ||
test('uses the custom errorMessage callback if passed in as an option', function (t) { | ||
var dest = split(JSON.parse) | ||
var customErrorMessage = 'Custom error message' | ||
var logger = pinoHttp({ | ||
const dest = split(JSON.parse) | ||
const customErrorMessage = 'Custom error message' | ||
const logger = pinoHttp({ | ||
customErrorMessage: function (err, res) { | ||
@@ -783,4 +800,4 @@ return customErrorMessage + ' ' + err.toString() | ||
test('uses custom log object attribute keys when provided, successful request', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ | ||
customAttributeKeys: { | ||
@@ -808,4 +825,4 @@ req: 'httpReq', | ||
test('uses custom log object attribute keys when provided, error request', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ | ||
customAttributeKeys: { | ||
@@ -834,3 +851,3 @@ req: 'httpReq', | ||
test('uses custom request properties to log additional attributes when provided', function (t) { | ||
var dest = split(JSON.parse) | ||
const dest = split(JSON.parse) | ||
function customPropsHandler (req, res) { | ||
@@ -844,3 +861,3 @@ if (req && res) { | ||
} | ||
var logger = pinoHttp({ | ||
const logger = pinoHttp({ | ||
customProps: customPropsHandler | ||
@@ -862,3 +879,3 @@ }, dest) | ||
test('uses old custom request properties interface to log additional attributes', function (t) { | ||
var dest = split(JSON.parse) | ||
const dest = split(JSON.parse) | ||
function customPropsHandler (req, res) { | ||
@@ -872,3 +889,3 @@ if (req && res) { | ||
} | ||
var logger = pinoHttp({ | ||
const logger = pinoHttp({ | ||
reqCustomProps: customPropsHandler | ||
@@ -890,4 +907,4 @@ }, dest) | ||
test('uses custom request properties to log additional attributes; custom props is an object instead of callback', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ | ||
customProps: { key1: 'value1' } | ||
@@ -908,4 +925,4 @@ }, dest) | ||
test('dont pass custom request properties to log additional attributes', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ | ||
customProps: undefined | ||
@@ -933,4 +950,4 @@ }, dest) | ||
t.plan(3) | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ autoLogging: true }, dest) | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ autoLogging: true }, dest) | ||
@@ -940,3 +957,3 @@ setup(t, logger, function (err, server) { | ||
doGet(server, null, function () { | ||
var line = dest.read() | ||
const line = dest.read() | ||
t.equal(line.msg, 'request completed') | ||
@@ -954,4 +971,4 @@ }) | ||
t.plan(8) | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ quietReqLogger: true }, dest) | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ quietReqLogger: true }, dest) | ||
@@ -969,3 +986,3 @@ function handler (req, res) { | ||
doGet(server, null, function () { | ||
var quietLine = dest.read() | ||
const quietLine = dest.read() | ||
t.equal(quietLine.msg, 'quiet message') | ||
@@ -975,3 +992,3 @@ t.equal(quietLine.reqId, 'testId') | ||
var responseLine = dest.read() | ||
const responseLine = dest.read() | ||
t.equal(responseLine.msg, 'request completed') | ||
@@ -986,4 +1003,4 @@ t.equal(responseLine.reqId, 'testId') | ||
t.plan(8) | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ quietReqLogger: true, customAttributeKeys: { reqId: 'customRequestId' } }, dest) | ||
const dest = split(JSON.parse) | ||
const logger = pinoHttp({ quietReqLogger: true, customAttributeKeys: { reqId: 'customRequestId' } }, dest) | ||
@@ -1001,3 +1018,3 @@ function handler (req, res) { | ||
doGet(server, null, function () { | ||
var quietLine = dest.read() | ||
const quietLine = dest.read() | ||
t.equal(quietLine.msg, 'quiet message') | ||
@@ -1007,3 +1024,3 @@ t.notOk(quietLine.req) | ||
var responseLine = dest.read() | ||
const responseLine = dest.read() | ||
t.equal(responseLine.msg, 'request completed') | ||
@@ -1010,0 +1027,0 @@ t.equal(responseLine.customRequestId, 'testId') |
Sorry, the diff of this file is not supported yet
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
47194
1056
4
+ Addedget-caller-file@^2.0.5
+ Addedget-caller-file@2.0.5(transitive)
+ Addedon-exit-leak-free@0.2.0(transitive)
+ Addedpino@7.11.0(transitive)
+ Addedreal-require@0.1.0(transitive)
+ Addedsafe-stable-stringify@2.5.0(transitive)
+ Addedsonic-boom@2.8.0(transitive)
+ Addedthread-stream@0.15.2(transitive)
- Removedfast-safe-stringify@2.1.1(transitive)
- Removedflatstr@1.0.12(transitive)
- Removedpino@6.14.0(transitive)
- Removedpino-std-serializers@3.2.0(transitive)
- Removedsonic-boom@1.4.1(transitive)
Updatedpino@^7.0.5