fastify/fastify-cli

Pino object logger option gets cloned after #568

開放

#574 建立於 2022年12月13日

 (11 則留言) (1 個反應) (0 位負責人)JavaScript (174 個分叉)github user discovery
bughelp wanted

倉庫指標

星標
 (726 顆星)
PR 合併指標
 (平均合併 54分鐘) (30 天內合併 3 個 PR)

描述

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.

貢獻者指南