Browse code

Show stacktrace in daemon logs only if 500 internal error

Signed-off-by: Tibor Vass <tibor@docker.com>

Tibor Vass authored on 2017/02/07 00:49:16
Showing 1 changed files
... ...
@@ -138,7 +138,12 @@ func (s *Server) makeHTTPHandler(handler httputils.APIFunc) http.HandlerFunc {
138 138
 		}
139 139
 
140 140
 		if err := handlerFunc(ctx, w, r, vars); err != nil {
141
-			logrus.Errorf("Handler for %s %s returned error: %+v", r.Method, r.URL.Path, err)
141
+			statusCode := httputils.GetHTTPErrorStatusCode(err)
142
+			errFormat := "%v"
143
+			if statusCode == http.StatusInternalServerError {
144
+				errFormat = "%+v"
145
+			}
146
+			logrus.Errorf("Handler for %s %s returned error: "+errFormat, r.Method, r.URL.Path, err)
142 147
 			httputils.MakeErrorHandler(err)(w, r)
143 148
 		}
144 149
 	}