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 messageFormat #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add messageFormat #51

wants to merge 1 commit into from

Conversation

cymen
Copy link

@cymen cymen commented Jan 5, 2016

This PR adds a new messageFormat option that is similar to logFormat but operates on the entire message (and passes the meta) whereas logFormat is run on each line of the message.

Example:

In an express app, I'm doing this:

    new winston.transports.Papertrail({
      colorize: false,
      host: 'some-papertrail-host.xyz',
      port: 12345,
      hostname: 'something',
      messageFormat: function(level, _, meta) {
        var msg = meta.req.method + ' ' + meta.req.url + ' ' + meta.res.statusCode + ' ' + meta.responseTime;
        console.log(msg);
        return msg;
      }
    })

@cymen cymen mentioned this pull request Jan 5, 2016
@gunnarlium
Copy link

This PR still has the problem that the meta is also part of the message. That is, if I want to include the message, but only some of the meta (or add extra meta), all the original meta is already part of the message.

I've made a simple fix in my own fork: gunnarlium@008e737

Would you consider incorporating something like this?

@chmac
Copy link

chmac commented May 21, 2016

@kenperkins Any thoughts on this? Would be great to be able to JSON.stringify() meta, which I assume would be possible with this PR.

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

Successfully merging this pull request may close these issues.

3 participants