gemnasium / logrus-graylog-hook

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

Nil pointer dereference #21

Open mannaz opened 7 years ago

mannaz commented 7 years ago

In case of unreachable graylog server GraylogHook.gelfLogger is silently initialized to nil: graylog_hook.go#L46 -> graylog_hook.go#L60 Then program crashes with nil pointer dereference on sending entry: graylog_hook.go#L146 -> graylog_hook.go#L208

I believe NewGraylogHook should return error and/or nil *GraylogHook or as a backward-compatible solution *GraylogHook should provide method to get initialization error.

gravis commented 7 years ago

Good catch! I have turned this in my head several times: I don't think workaround solutions are better than returning the error in the initializer. As this is a breaking API change, we'll use gopkg.in to bump to 3.0 (that doesn't really make sense, but unless we have a real package manager in go, that's the way to go).

Thanks, I'll publish the new version in a few minutes.

gravis commented 7 years ago

1st step, fixing this for 2.x branch, so current user won't be affected. Next step, 3.x branch with different api.