airbrake / gobrake

Airbrake notifier for Golang
https://docs.airbrake.io/docs/platforms/go-lang
MIT License
104 stars 42 forks source link

Auto-notify when logging at the error level #294

Closed dsuare1 closed 2 years ago

dsuare1 commented 2 years ago

I'm using the zap logging library and have recently added airbrake to the project.

I followed the quick example and configured my airbrake notifier with the correct project id and key, then manually called airbrake.Notify(...) and saw the error reported in my project. So I can confirm that the connection is working as expected.

My issue is that I don't want to have to go through my entire codebase and insert manual calls to airbrake.Notify(...) where relevant, but would rather configure airbrake to do so every time something is logged at the error level.

Is there a way to do this?

chimanjain commented 2 years ago

Hi @dsuare1, currently we don't have an integration with zap logging library, but we have put this in our to do list to support zap logging library.

dsuare1 commented 2 years ago

Thanks @chimanjain - I was able to achieve what I wanted using zap's hooks. Only issue was that I had to refactor the initialization of my logger to take in the *gobrake.Notifier.

chimanjain commented 2 years ago

Hi @dsuare1, I started working on zap integration with gobrake and I found an issue with zap's hooks that it doesn't capture []zapcore.Field. So I created a zap Core in #299 which sends the zap logs to airbrake.