You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What problem are you trying to solve?
When a hapi event containing an error is logged by hapi-pino, then those errors are logged with very few context. This is specially true for server logs, where usually the context is provided by the plugin itself through the use of tags:
'use strict';constHapi=require('@hapi/hapi');constPino=require('hapi-pino');constPluginA={name: 'plugin-a',register(server){constlog=()=>server.log(['error','plugin-a','operation-a'],newError('Operation failed with error'));server.ext('onPreStart',log);}};constPluginB={name: 'plugin-b',register(server){constlog=()=>server.log(['error','plugin-b','operation-b'],newError('Operation failed with error'));server.ext('onPreStart',log);}};asyncfunctionrun(){constserver=Hapi.Server();awaitserver.register([Pino,PluginA,PluginB]);returnserver.initialize();}run();
What did you get?
When the code above is executed, the additional information provided through the use of tags is missing from the log.
{"level":50,"time":1638469266007,"pid":6306,"hostname":"codespaces_02ef33","err":{"type":"Error","message":"Operation failed with error","stack":"Error: Operation failed with error\n at log (/workspaces/hapi-pino-test-sandbox/server-logs-error-test.js:9:76)\n at module.exports.internals.Core._invoke (/workspaces/hapi-pino-test-sandbox/node_modules/@hapi/hapi/lib/core.js:490:40)\n at module.exports.internals.Core._initialize (/workspaces/hapi-pino-test-sandbox/node_modules/@hapi/hapi/lib/core.js:368:24)\n at processTicksAndRejections (internal/process/task_queues.js:95:5)"},"msg":"Operation failed with error"}
{"level":50,"time":1638469266008,"pid":6306,"hostname":"codespaces_02ef33","err":{"type":"Error","message":"Operation failed with error","stack":"Error: Operation failed with error\n at log (/workspaces/hapi-pino-test-sandbox/server-logs-error-test.js:17:76)\n at module.exports.internals.Core._invoke (/workspaces/hapi-pino-test-sandbox/node_modules/@hapi/hapi/lib/core.js:490:40)\n at processTicksAndRejections (internal/process/task_queues.js:95:5)\n at async module.exports.internals.Core._initialize (/workspaces/hapi-pino-test-sandbox/node_modules/@hapi/hapi/lib/core.js:368:13)"},"msg":"Operation failed with error"}
What did you expected?
I expected the tags information to be preserved on server logs.
The text was updated successfully, but these errors were encountered:
What problem are you trying to solve?
When a hapi event containing an error is logged by hapi-pino, then those errors are logged with very few context. This is specially true for server logs, where usually the context is provided by the plugin itself through the use of tags:
What did you get?
When the code above is executed, the additional information provided through the use of tags is missing from the log.
What did you expected?
I expected the tags information to be preserved on server logs.
The text was updated successfully, but these errors were encountered: