graygelf icon indicating copy to clipboard operation
graygelf copied to clipboard

Pass remote.address and remote.port to emitted message

Open megastef opened this issue 8 years ago • 1 comments

On the server side it would be interesting to know from where the packets arrive. The UDP socket provides this details, but the message processing ignores this info.

megastef avatar Oct 24 '17 14:10 megastef

GELF requires host to be set in the message, but I suppose that could be set improperly by the client, and likely wouldn't include the port. You can sniff those details by adding your own event handler currently, e.g.

var gelfserver = require('graygelf/server')
var server = gelfserver()
server.on('message', function (gelf) {
  // handle parsed gelf json here
  console.log('received message', gelf.short_message)
})
server.listen(12201)
server._udp.on('message', function (buf, rinfo) {
  // view raw packet info here
  console.log(rinfo)
}

wavded avatar Oct 24 '17 14:10 wavded