fastify/fastify-cli

Pino object logger option gets cloned after #568

オープン

#574 opened on 2022/12/13

 (11 件のコメント) (1 件のリアクション) (0 人の担当者)JavaScript (174 件のフォーク)github user discovery
bughelp wanted

Repository metrics

Stars
 (726 個のスター)
PR merge metrics
 (平均マージ 54m) (30d で 3 merged PRs)

説明

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.

コントリビューターガイド