xmidt-org / argus

simple json database abstraction layer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Log Server Error

kristinapathak opened this issue · comments

The Error Encoder has the most knowledge about the error as it has been decorated up the stack, so we want to log it. We can also log the status code being returned for this request, which may not be logged anywhere else.

func encodeError(ctx context.Context, err error, w http.ResponseWriter) {

We gain access to a logger by acquiring it from the context passed to the error encoder. Then, the logger will also be decorated with other request-specific fields.