namshi / winston-graylog2

Graylog2 transport for winston, a nodejs logging module
MIT License
126 stars 98 forks source link

Customize Message Length in winston graylog? #51

Open LingboTang opened 6 years ago

LingboTang commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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