xmidt-org / argus

simple json database abstraction layer
Apache License 2.0
3 stars 9 forks source link

Configure logger for gokit handlers #153

Open joe94 opened 3 years ago

joe94 commented 3 years ago

The handlers in this file https://github.com/xmidt-org/argus/blob/main/store/handler.go#L40 could be configured with gokit's ServerErrorHandler option to at least log all the errors.

joe94 commented 3 years ago

After @kristinapathak pointed out that the docs explicitly say that logging should be done in the ServerErrorEncoder even when the ServerErrorLogger got deprecated for the ServerErrorHandler, I think (if we're interested in logging errors such as "ItemNotFound"), we could log them at the debug level in the ServerErrorEncoder Source: https://pkg.go.dev/github.com/go-kit/kit/transport/http#ServerErrorHandler

ServerErrorHandler is used to handle non-terminal errors. 
By default, non-terminal errors are ignored. This is intended as a diagnostic measure. 
Finer-grained control of error handling, including logging in more detail, should be performed 
in a custom ServerErrorEncoder or ServerFinalizer, both of which have access to the context.