mhart / gelf-stream

A node.js stream to send JS objects to a Graylog2 server (in GELF format)
Other
29 stars 13 forks source link

How to filter out unwanted messages? #14

Closed elvanja closed 8 years ago

elvanja commented 8 years ago

I'm using this for bunyan logging stream, via #forBunyan. Is there a way to filter out only certain messages to be sent to graylog?

I tried it with options.filter, like this:

gelfStream.forBunyan(config.graylogHost, config.graylogPort, {
  filter: function filter(chunk) {
    console.log('**** in gelf stream #filter ****');
    return false; // or some arbitrary decision, based on `chunk`
  }
});

But, the first time the filter function returns false, no other message/chunk is ever sent to graylog. The idea is based on https://github.com/mhart/gelf-stream/blob/master/gelf-stream.js#L29, but I am probably missing something here.

Anyway, any pointer to to how to filter out / send only desired messages would be great. Thank you!

mhart commented 8 years ago

You're absolutely right! This should be fixed in v1.1.1 – thanks for reporting!

elvanja commented 8 years ago

Thank you! :)