gemnasium / logrus-graylog-hook

Graylog hook for logrus
MIT License
87 stars 62 forks source link

Add no compress writer #24

Closed yuancheng-p closed 7 years ago

yuancheng-p commented 7 years ago

Our graylog config doesn't accept compressed messages (gzip / zip), but only the plain text.

In order to support this, I add a buffered writer which will not add any compression header info.

To use this, we need to reset the writer of the hook before adding it to the log.

        addr :="localhost"
        hook := graylog.NewGraylogHook(
            addr,
            map[string]interface{}{},
        )

        // reset the writer
        writer, _ := graylog.NewWriter(addr)
        writer.CompressionType = graylog.NoCompress
        hook.SetWriter(writer)

        log.AddHook(hook)
yuancheng-p commented 7 years ago

Hi @gravis, I've add this for our needs. Maybe this no-compression option should be considered added to the library?

gravis commented 7 years ago

According to http://docs.graylog.org/en/2.2/pages/gelf.html:

GELF messages can be sent uncompressed, GZIP’d or ZLIB’d

So we're clearly miss a feature here. Thanks for your PR