winston-graylog2 icon indicating copy to clipboard operation
winston-graylog2 copied to clipboard

Customize Message Length in winston graylog?

Open LingboTang opened this issue 7 years ago • 2 comments

I'm using this package recently and I found a problem that only the first 100 characters of a log message are log to graylog because of this line:

this.graylog2[getMessageLevel(level)](msg.substring(0, 100), msg, meta);

and I have to drill down multiple list to see the entire message. I made a change to get rid of the substring function and then it works for me.

For design perspective, this is a dirty change that I shouldn't made for my project, and I didn't see that there is a way that we can through this in configuration level currently, so I'm asking if someone can wrap it up and give us the option so that we can pass in the message length as a parameter.

LingboTang avatar Sep 21 '17 17:09 LingboTang

It could be changed to:

this.graylog2[getMessageLevel(level)](msg, '', meta);

to enable the full message, but we could give the number of characters as a parameters like:

Graylog2.prototype.log = function(level, msg, msg_len, meta, callback) {
  meta = this.processMeta(prepareMeta(meta, this.staticMeta));
  msg  = this.prelog(msg);

  this.graylog2[getMessageLevel(level)](msg.substring(0, msg_len), msg, meta);
  callback(null, true);
};

Maybe a quick change?

LingboTang avatar Sep 22 '17 21:09 LingboTang

It's more like a feature request that we would like to add short_message/full_message as an option.

LingboTang avatar Sep 25 '17 20:09 LingboTang