Skip to content

Commit

Permalink
Merge pull request #103 from vansante/logging
Browse files Browse the repository at this point in the history
Add info logs for succeeded http handlers with local changes
  • Loading branch information
vansante authored Jul 19, 2024
2 parents b8ff0fb + 70a84f2 commit 8457150
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions http/http_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ func (h *HTTP) setProperties(w http.ResponseWriter, req *http.Request, ds *zfs.D
return
}

logger.Info("zfs.http.setProperties: Properties set",
"dataset", ds.Name, "properties", props,
)

w.WriteHeader(http.StatusOK)
err = json.NewEncoder(w).Encode(ds)
if err != nil {
Expand Down Expand Up @@ -309,6 +313,10 @@ func (h *HTTP) handleReceiveSnapshot(w http.ResponseWriter, req *http.Request, l
return
}

logger.Info("zfs.http.handleReceiveSnapshot: Received snapshot",
"dataset", receiveDataset, "properties", props,
)

w.WriteHeader(http.StatusCreated)
err = json.NewEncoder(w).Encode(ds)
if err != nil {
Expand Down Expand Up @@ -508,6 +516,8 @@ func (h *HTTP) handleMakeSnapshot(w http.ResponseWriter, req *http.Request, logg
return
}

logger.Info("zfs.http.handleMakeSnapshot: Snapshot created", "dataset", ds.Name)

w.WriteHeader(http.StatusCreated)
err = json.NewEncoder(w).Encode(ds)
if err != nil {
Expand Down Expand Up @@ -553,6 +563,11 @@ func (h *HTTP) handleDestroyFilesystem(w http.ResponseWriter, req *http.Request,
w.WriteHeader(http.StatusInternalServerError)
return
}

logger.Info("zfs.http.handleDestroyFilesystem: Filesystem removed",
"filesystem", filesystem, "dataset", ds.Name,
)

w.WriteHeader(http.StatusNoContent)
}

Expand Down Expand Up @@ -598,5 +613,8 @@ func (h *HTTP) handleDestroySnapshot(w http.ResponseWriter, req *http.Request, l
w.WriteHeader(http.StatusInternalServerError)
return
}

logger.Info("zfs.http.handleDestroySnapshot: Snapshot removed", "dataset", ds.Name)

w.WriteHeader(http.StatusNoContent)
}

0 comments on commit 8457150

Please sign in to comment.