Pino object logger option gets cloned after #568
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 733
- Fork
- 178
- Merge medio
- 1g 20h
- PR unite (30g)
- 3
Descrizione
Prerequisites
- I have written a descriptive issue title
- 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:
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo il problema con il modulo di avvio fornito e node_modules/.bin/fastify start --options a.js, quindi esamina la gestione delle opzioni e il comportamento di deepmerge introdotto dopo #568. Il lavoro è completato quando il logger Pino fornito mantiene le proprie impostazioni e produce l'output pretty previsto; aggiungi o aggiorna la coverage per questa riproduzione se viene individuata un'area di test esistente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, node.js
- Ambito
- cli
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Attiva
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 65/100