Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Incorrect readme.md example #76

Open
vjpr opened this issue Aug 25, 2021 · 1 comment
Open

Incorrect readme.md example #76

vjpr opened this issue Aug 25, 2021 · 1 comment

Comments

@vjpr
Copy link

vjpr commented Aug 25, 2021

https://github.com/pinojs/express-pino-logger#custom-serializers

'use strict'

var app = require('express')()
+ var ExpressPinoLogger = require('express-pino-logger')
- var ExpressPinoLogger = require('express-pino-logger')() <-------- remove the `()` because we pass `serializers` below.

var pino = ExpressPinoLogger({
  serializers: {
    req: (req) => ({
      method: req.method,
      url: req.url,
      user: req.raw.user,
    }),
  },
})

// middleware that augments the req - must be added before the pino middleware
app.use((req, res, next) => {
  req.user = 'testing';
  next();
})

app.use(pino)
@mcollina
Copy link
Member

Good spot! Would you like to send a Pull Request to address this issue?

molomby added a commit to molomby/express-pino-logger that referenced this issue Sep 21, 2021
The current example invokes the ExpressPinoLogger constructor twice, which throws in init:

```
TypeError: Cannot set property 'log' of undefined
    at loggingMiddleware (/repos/app/node_modules/pino-http/logger.js:99:23)
```

Fix for pinojs#76
mcollina pushed a commit that referenced this issue Sep 21, 2021
The current example invokes the ExpressPinoLogger constructor twice, which throws in init:

```
TypeError: Cannot set property 'log' of undefined
    at loggingMiddleware (/repos/app/node_modules/pino-http/logger.js:99:23)
```

Fix for #76
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants