0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-16 21:56:37 -05:00

routes: add more logs

There still appears to be another path where we are seeing 500s.
Adding more logs to catch this path.
This commit is contained in:
Ramkumar Chinchani 2020-01-06 16:21:46 -08:00
parent 2b9d29c9a2
commit 31b30d858b
2 changed files with 6 additions and 4 deletions

View file

@ -267,7 +267,9 @@ func (rh *RouteHandler) UpdateManifest(w http.ResponseWriter, r *http.Request) {
body, err := ioutil.ReadAll(r.Body) body, err := ioutil.ReadAll(r.Body)
if err != nil { if err != nil {
rh.c.Log.Error().Err(err).Msg("unexpected error")
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)
return return
} }
@ -605,7 +607,6 @@ func (rh *RouteHandler) GetBlobUpload(w http.ResponseWriter, r *http.Request) {
// @Failure 500 {string} string "internal server error" // @Failure 500 {string} string "internal server error"
// @Router /v2/{name}/blobs/uploads/{uuid} [patch] // @Router /v2/{name}/blobs/uploads/{uuid} [patch]
func (rh *RouteHandler) PatchBlobUpload(w http.ResponseWriter, r *http.Request) { 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) vars := mux.Vars(r)
name, ok := vars["name"] name, ok := vars["name"]
@ -894,7 +895,7 @@ func WriteJSON(w http.ResponseWriter, status int, data interface{}) {
body, err := json.Marshal(data) body, err := json.Marshal(data)
if err != nil { if err != nil {
w.WriteHeader(http.StatusInternalServerError) panic(err)
} }
WriteData(w, status, DefaultMediaType, body) WriteData(w, status, DefaultMediaType, body)
@ -920,7 +921,8 @@ func WriteDataFromReader(w http.ResponseWriter, status int, length int64, mediaT
break break
} else if err != nil { } else if err != nil {
// other kinds of intermittent errors can occur, e.g, io.ErrShortWrite // 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
} }
} }
} }

View file

@ -40,7 +40,7 @@ func NewLogger(level string, output string) Logger {
log = zerolog.New(file) log = zerolog.New(file)
} }
return Logger{Logger: log.With().Timestamp().Logger()} return Logger{Logger: log.With().Caller().Timestamp().Logger()}
} }
type statusWriter struct { type statusWriter struct {