Open ghost opened 5 years ago
Can you send a full example to reproduce thia?
this module is also out of date. Would you like to send a PR to update the dependencies?
sorry for delay... example server:
const Hapi = require('hapi')
const server = Hapi.server({
host: 'localhost',
port: 8000
})
server.route({
method: 'GET',
path: '/hello',
handler: function (request, h) {
return 'hello world'
}
})
const start = async function () {
try {
await server.register({
plugin: require('hapi-pino')
})
await server.start()
} catch (err) {
console.log(err)
process.exit(1)
}
server.log(['server', 'start'], `Server running at: ${server.info.uri}`)
}
start()
from the package.json
"dependencies": {
"hapi": "^18.1.0",
"hapi-pino": "^5.4.1",
"pino-clf": "^1.0.6"
}
and the error:
/Users/example/node_modules/pino-toke/tokens.js:58
return o.res.header.substr(0, 8).split('/')[1]
^
TypeError: Cannot read property 'substr' of undefined
at Object.http-version (/Users/example/node_modules/pino-toke/tokens.js:58:25)
at eval (eval at compile (/Users/example/node_modules/pino-toke/index.js:37:10), <anonymous>:3:244)
at DestroyableTransform._transform (/Users/example/node_modules/pino-toke/index.js:26:14)
at DestroyableTransform.Transform._read (/Users/example/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at DestroyableTransform.Transform._write (/Users/example/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:83)
at doWrite (/Users/example/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:428:64)
at writeOrBuffer (/Users/example/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:417:5)
at DestroyableTransform.Writable.write (/Users/example/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:334:11)
at DestroyableTransform.ondata (/Users/example/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:619:20)
at emitOne (events.js:116:13)
Ouch! Would you like to send a PR to fix this? This seems an incompatibility with hapi v17 in https://github.com/pinojs/pino-toke/blob/master/tokens.js.
Honestly, this package seems severely outdated, it does not even work with express 4.
this is the error:
in may npm scripts, I am basically doing this: NODE_ENV=development node-dev --inspect --no-deps --respawn ./index.js | pino-clf
and registering the hapi-pino with no options.