Skip to content

Commit

Permalink
docs: minor tweak to pino-http example (#172)
Browse files Browse the repository at this point in the history
This tries to better mimic pino-http's express usage example
https://github.com/pinojs/pino-http#use-as-express-middleware
and points to a user-provided gist configuring pino to
work past this 'req' field limitation.
  • Loading branch information
trentm authored Dec 21, 2023
1 parent fbea3e4 commit 48195db
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/ecs-pino-format/examples/express-with-pino-http.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// This shows how one could use @elastic/ecs-pino-format with Express and
// the https://github.com/pinojs/pino-http middleware maintained by the Pino
// team.
// TODO: doc the log.child({req}) limitation
// TODO: doc the log.child({req}) limitation. See https://github.com/elastic/ecs-logging-nodejs/issues/102 and https://gist.github.com/gkampitakis/b36819f38f8886598c20ed1af7245e3a
// TODO: doc pino-http's 'req.id' and ECS translation to 'event.id'

const { ecsFormat } = require('../') // @elastic/ecs-pino-format
Expand All @@ -37,7 +37,7 @@ app.use(pinoHttp({ logger: log }))
app.get('/', function (req, res, next) {
res.setHeader('Foo', 'Bar')
res.end('hi')
res.log.info({ req, res }, 'hi there')
req.log.info('in app.get / handler')
})
app.get('/error', function (req, res, next) {
return next(new Error('boom'))
Expand Down

0 comments on commit 48195db

Please sign in to comment.