Skip to content

Commit

Permalink
bottleneck http error logging in root handler
Browse files Browse the repository at this point in the history
Signed-off-by: Riyaz Faizullabhoy <[email protected]>
  • Loading branch information
riyazdf committed Jun 23, 2016
1 parent a982798 commit b886d6a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions utils/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ func (root *rootHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
ctx = authCtx
}
if err := root.handler(ctx, w, r); err != nil {
if httpErr, ok := err.(errcode.ErrorCode); ok {
// info level logging for non-5XX http errors
httpErrCode := httpErr.Descriptor().HTTPStatusCode
if httpErrCode > http.StatusOK && httpErrCode < http.StatusInternalServerError {
logrus.Info(httpErr)
} else if httpErrCode >= http.StatusInternalServerError {
// error level logging for 5XX http errors
logrus.Error(httpErr)
}
}
e := errcode.ServeJSON(w, err)
if e != nil {
logrus.Error(e)
Expand Down

0 comments on commit b886d6a

Please sign in to comment.