Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: method logger.child({defaultMeta: true}) doesen't add default meta object in the splat property of the info object #2168

Open
ghost opened this issue Jul 22, 2022 · 1 comment

Comments

@ghost
Copy link

ghost commented Jul 22, 2022

馃攷 Search Terms

child,logger.child meta

The problem

When doing

const { transports, createLogger } = require('winston');

 const logger = createLogger({
      transports: [transports.Console({level: 'silly'})],
  });

logger.info('info message', {meta: true}, 'one', 'two', 3);

The 'info' object will be

{
  level: 'info',
  message: 'info message',
  meta: true,
  Symbol('level'): 'info',
  Symbol('message'): '{"level":"info","message":"info2","meta": true}',
  Symbol('splat'):  [{meta: true}, 'one', 'two', 3], // correct
}

But when a child logger is spawned

const { transports, createLogger } = require('winston');

 const logger = createLogger({
      transports: [transports.Console({level: 'silly'})],
 });

const child = logger.child({meta: true});

child.info('info message', 'one', 'two', 3);

The 'info' object will be

{
  level: 'info',
  message: 'info message',
  meta: true,
  Symbol('level'): 'info',
  Symbol('message'): '{"level":"info","message":"info2","meta": true}',
  Symbol('splat'):  ['one', 'two', 3], // wrong
}

The splat is missing the provided default meta object

What version of Winston presents the issue?

3.8.1

What version of Node are you using?

16.13.2

If this worked in a previous version of Winston, which was it?

No response

Minimum Working Example

const { transports, createLogger } = require('winston');

const logger = createLogger({
    transports: [transports.Console({level: 'silly'})],
  });

logger.info('info message', {meta: true}, 'one', 'two', 3); // splat correct here

const child = logger.child({meta: true});

child.info('info message', 'one', 'two', 3) // splat wrong here, missing "{meta: true}"

Additional information

No response

@wbt
Copy link
Contributor

wbt commented Aug 5, 2022

Does this work any better in 3.7.1 specifically? That version had some changes to how metadata was handled which were quickly rolled back, but it'd be useful to know if they fixed this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant