Pino object logger option gets cloned after #568
- Dominant language
- JavaScript
- Stars
- 733
- Forks
- 177
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 3
Description
### Prerequisites
- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the bug has not already been reported
### Fastify version
4.10.2
### Plugin version
5.7.0
### Node.js version
18.12.1
### Operating system
macOS
### Operating system version (i.e. 20.04, 11.3, 10)
13.0.1
### Description
After #568 was merged, the new behavior of `deepmerge` clone the `options` object and tries to clone any instance of Pino we pass as option, modifying it into a simple object so that all the Pino settings are lost.
### Steps to Reproduce
Given the following fastify startup module:
```javascript
import pino from 'pino';
export default async function (fastify, options) {
fastify.get('/', async (req, reply) => ({ hello: 'world' }));
}
const logger = pino({
transport: {
target: 'pino-pretty',
},
});
export const options = {
logger,
};
```
When using fastify-cli like this:
node_modules/.bin/fastify start --options a.js
I get this output:
{"level":30,"time":1670931640310,"pid":68940,"hostname":"Stefanos-MacBook-Air.local","msg":"Server listening at http://[::1]:3000"}
{"level":30,"time":1670931640311,"pid":68940,"hostname":"Stefanos-MacBook-Air.local","msg":"Server listening at http://127.0.0.1:3000"}
### Expected Behavior
The expected output would be something like this instead:
[12:41:03.421] INFO (69034): Server listening at http://[::1]:3000
[12:41:03.422] INFO (69034): Server listening at http://127.0.0.1:3000
I would tend to think that `deepmerge` should be modified in order to clone by reference any type of object that is not a plain JS object, but I'd appreciate any feedback in order to try and provide a patch for this.
Contributor guide
Assessment
This issue has not been assessed yet.