gemnasium / logrus-graylog-hook

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

Remove facility #9

Closed saward closed 8 years ago

saward commented 8 years ago

According to the documentation, 'facility' is deprecated and should be included as an additional field instead if wanted:

http://docs.graylog.org/en/2.0/pages/gelf.html

gravis commented 8 years ago

Indeed. As it's a breaking change in the API, I need to create a new tag for gopkg.in for a v2. I will merge your branch this week. Thanks!

saward commented 8 years ago

Sounds good! While you're considering breaking changes, I'd suggest that you change the hook to return an error if it can't connect, rather than try to log the error itself and continue on.

E.g.:

// NewGraylogHook creates a hook to be added to an instance of logger.
func NewGraylogHook(addr string, extra map[string]interface{}) (*GraylogHook, error) {
    g, err := gelf.NewWriter(addr)
    if err != nil {
        return nil, err
    }
    hook := &GraylogHook{
        Extra:       extra,
        gelfLogger:  g,
        synchronous: true,
    }
    return hook, nil
}

This is what I have done in the master branch of my fork.

gravis commented 8 years ago

merged in v2.0.0