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.

贡献者指南