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

Pass meta data into logFormat() #41

Closed
ricolo opened this issue Jun 6, 2015 · 7 comments
Closed

Pass meta data into logFormat() #41

ricolo opened this issue Jun 6, 2015 · 7 comments

Comments

@ricolo
Copy link

ricolo commented Jun 6, 2015

Currently, logFormat() input arguments are level and message, and I wonder if meta data can also be passed into the function for reformatting.

I use meta data to identify the log from different components of my system, so it may not be the best way to display if it is only printed at the end of the log message for meta data. Winston's file and console transport also provide meta data for the log formatter.

@cymen
Copy link

cymen commented Jan 4, 2016

I misread your issue. I did a PR for something else but it would be nice to get the meta in too.

@cymen
Copy link

cymen commented Jan 4, 2016

@ricolo I opened a PR that adds this: #50

If that gets merged, you can do:

logFormat: function(level, message, originalMessage, meta) {
  return 'META ' + meta;
}

Note that winston-paptertrail formats the message and I opened the PR as I want the original message so I can format it. So that 3rd parameter (originalMessage) may not be interesting to you but would be present.

@cymen
Copy link

cymen commented Jan 5, 2016

@ricolo The fix is now in PR #51. It turned out I needed meta too not another part so I added a new option that is messageFormat (#51 has an example).

@ricolo
Copy link
Author

ricolo commented Jan 6, 2016

Thanks a lot @cymen, would you also modify the documentation (e.g. https://github.com/kenperkins/winston-papertrail#advanced-usage) as well to reflect the expanded capability?

@cymen
Copy link

cymen commented Jan 6, 2016

@ricolo I did in PR #51 but it hasn't been merged yet. I needed this ASAP so I temporarily put a fork of this out here:

https://www.npmjs.com/package/winston-papertrail-enhanced

You could try that to get the functionality. But hopefully #51 will get in soon and I'll deprecate my fork. The documentation is here:

https://www.npmjs.com/package/winston-papertrail-enhanced#messageformat

@ricolo
Copy link
Author

ricolo commented Jan 6, 2016

@cymen I overlooked it, thanks!

@ricolo ricolo closed this as completed Jan 6, 2016
@matteocontrini
Copy link

This issue should stay open as long as the PR is open.

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

No branches or pull requests

3 participants