Skip to content

Commit

Permalink
Merge pull request #56 from rchincha/500-status
Browse files Browse the repository at this point in the history
routes: add more logs
  • Loading branch information
rchamarthy authored Jan 7, 2020
2 parents 2b9d29c + 31b30d8 commit 2501182
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions pkg/api/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ func (rh *RouteHandler) UpdateManifest(w http.ResponseWriter, r *http.Request) {

body, err := ioutil.ReadAll(r.Body)
if err != nil {
rh.c.Log.Error().Err(err).Msg("unexpected error")
w.WriteHeader(http.StatusInternalServerError)

return
}

Expand Down Expand Up @@ -605,7 +607,6 @@ func (rh *RouteHandler) GetBlobUpload(w http.ResponseWriter, r *http.Request) {
// @Failure 500 {string} string "internal server error"
// @Router /v2/{name}/blobs/uploads/{uuid} [patch]
func (rh *RouteHandler) PatchBlobUpload(w http.ResponseWriter, r *http.Request) {
rh.c.Log.Info().Interface("headers", r.Header).Msg("request headers")
vars := mux.Vars(r)
name, ok := vars["name"]

Expand Down Expand Up @@ -894,7 +895,7 @@ func WriteJSON(w http.ResponseWriter, status int, data interface{}) {
body, err := json.Marshal(data)

if err != nil {
w.WriteHeader(http.StatusInternalServerError)
panic(err)
}

WriteData(w, status, DefaultMediaType, body)
Expand All @@ -920,7 +921,8 @@ func WriteDataFromReader(w http.ResponseWriter, status int, length int64, mediaT
break
} else if err != nil {
// other kinds of intermittent errors can occur, e.g, io.ErrShortWrite
logger.Panic().Err(err).Msg("copying data into http response")
logger.Error().Err(err).Msg("copying data into http response")
return
}
}
}
2 changes: 1 addition & 1 deletion pkg/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewLogger(level string, output string) Logger {
log = zerolog.New(file)
}

return Logger{Logger: log.With().Timestamp().Logger()}
return Logger{Logger: log.With().Caller().Timestamp().Logger()}
}

type statusWriter struct {
Expand Down

0 comments on commit 2501182

Please sign in to comment.