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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deep merge meta objects #1884

Closed
1 task
okaybroda opened this issue Feb 7, 2021 · 2 comments
Closed
1 task

Deep merge meta objects #1884

okaybroda opened this issue Feb 7, 2021 · 2 comments

Comments

@okaybroda
Copy link

okaybroda commented Feb 7, 2021

Please tell us about your environment:

  • winston version?
    • winston@2
    • [✓] winston@3
  • Operating System? Linux
  • Language? all

What is the problem?

Merging meta objects is not working because of Object.assign which is a shallow merge.

What do you expect to happen instead?

Example code:

const logger = winston.createLogger({
      defaultMeta: {
        labels: {
          service: 'user-service'
        }
      },
    });
const childLogger = logger.child({ labels: { requestId: '451' } });
childLogger.info('dummy message', { labels: { yeet: 'yeet' } });

Current Output

{ labels: { yeet: 'yeet' } }

Expected Output

{ labels: { service: 'user-service', yeet: 'yeet', requestId: '451' } }

What's the feature?

Deep merge meta objects using lodash.merge

Is the absence of this feature blocking you or your team? If so, how?

In our case, we are using the Elastic Common Schema which recommends meta fields to go under the label object but we can't make child logger with additional metadata due to the shallow merge. Reference to ECS: link

Is this feature similar to an existing feature in another tool?

Not sure.

Is this a feature you're prepared to implement, with support from us?

Yes.

@okaybroda
Copy link
Author

Working on final touches on the PR.

@maverick1872
Copy link
Member

Closing as this issue is being consolidated into #2029

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

Successfully merging a pull request may close this issue.

2 participants