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

Add an option to log meta data at the top level #35

Merged
merged 2 commits into from Oct 3, 2019

Conversation

@mooski
Copy link
Contributor

commented Oct 3, 2019

Closes #34

@mgibeau
mgibeau approved these changes Oct 3, 2019
Copy link
Member

left a comment

Thanks for the PR, changes look good, would you mind adding a note in the readme as well?

this.channel = options.pchannel || options.channel;
this.pattern = options.pattern || !!options.pchannel;
this.metadata = options.meta || {};
this.logMetaAtTopLevel = options.logMetaAtTopLevel || false;

This comment has been minimized.

Copy link
@mgibeau

mgibeau Oct 3, 2019

Member

What would you think of flatMeta instead?

@mooski

This comment has been minimized.

Copy link
Contributor Author

commented Oct 3, 2019

I've changed the property name as you suggested and added a description of the property to the readme.

One thing I found peculiar is that the tests are behaving differently to my own test implementation. Given that I've set flatMeta to true, the tests don't log any meta data, whereas my own implementation logs this data as expected. I'm not sure why.

There's an obvious alternative implementation that would solve this problem (JSON.stringify({ level, message, ...meta })), but it seems like extra unnecessary work just for the benefit of the tests.

@mgibeau

This comment has been minimized.

Copy link
Member

commented Oct 3, 2019

I'm good the the changes as is, will take a look at the tests, I've been meaning to improve them for the longest time anyways :) Thanks!

@mgibeau mgibeau merged commit 4f9c4f8 into winstonjs:master Oct 3, 2019
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@mooski

This comment has been minimized.

Copy link
Contributor Author

commented Oct 4, 2019

Thanks for merging this!

Would it be possible to push the latest version to NPM so we can consume this change?

@nfedyk

This comment has been minimized.

Copy link

commented Oct 14, 2019

Thanks for doing this. Is there are plan for a release version so this feature can be utilized?

@mooski

This comment has been minimized.

Copy link
Contributor Author

commented Oct 15, 2019

@nfedyk It's not ideal, but we needed this feature too so I took this liberty of publishing it to npm here if that helps: https://www.npmjs.com/package/@mooski/winston-redis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.