winston-papertrail
winston-papertrail copied to clipboard
Add messageFormat
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;
}
})
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: https://github.com/gunnarlium/winston-papertrail/commit/008e737f54e4c4f25d2b1242764bf7df154fe494
Would you consider incorporating something like this?
@kenperkins Any thoughts on this? Would be great to be able to JSON.stringify()
meta, which I assume would be possible with this PR.