fix: improved logging

This commit is contained in:
2026-08-31 19:19:08 +02:00
parent 491b8da1ac
commit 2e16eefaba
3 changed files with 15 additions and 10 deletions
+14 -8
View File
@@ -54,7 +54,7 @@ func (h *ListHandler) CreateList(w http.ResponseWriter, r *http.Request) {
return return
} }
slog.InfoContext(ctx, "created list successfully", slog.Any("list_id", list.ID)) slog.InfoContext(ctx, "created list successfully", slog.String("list_id", list.ID))
response.JSON(ctx, w, http.StatusCreated, list) response.JSON(ctx, w, http.StatusCreated, list)
} }
@@ -94,7 +94,7 @@ func (h *ListHandler) DeleteList(w http.ResponseWriter, r *http.Request) {
return return
} }
slog.InfoContext(ctx, "deleted list successfully", slog.Any("list_id", listID)) slog.InfoContext(ctx, "deleted list successfully", slog.String("list_id", listID))
response.Status(w, http.StatusNoContent) response.Status(w, http.StatusNoContent)
} }
@@ -174,7 +174,10 @@ func (h *ListHandler) AddUserToList(w http.ResponseWriter, r *http.Request) {
return return
} }
slog.InfoContext(ctx, "added user to list successfully", slog.Any("list_id", payload.ListID), slog.Any("email", user.Email)) slog.InfoContext(ctx, "added user to list successfully",
slog.String("list_id", payload.ListID),
slog.String("email", user.Email),
)
response.Status(w, http.StatusNoContent) response.Status(w, http.StatusNoContent)
} }
@@ -222,7 +225,10 @@ func (h *ListHandler) RemoveUserFromList(w http.ResponseWriter, r *http.Request)
return return
} }
slog.InfoContext(ctx, "removed user from list successfully", slog.Any("list_id", payload.ListID), slog.Any("email", user.Email)) slog.InfoContext(ctx, "removed user from list successfully",
slog.String("list_id", payload.ListID),
slog.String("email", user.Email),
)
response.Status(w, http.StatusNoContent) response.Status(w, http.StatusNoContent)
} }
@@ -262,7 +268,7 @@ func (h *ListHandler) CreateListItem(w http.ResponseWriter, r *http.Request) {
return return
} }
slog.InfoContext(ctx, "created list item successfully", slog.Any("list_item_id", item.ID)) slog.InfoContext(ctx, "created list item successfully", slog.String("list_item_id", item.ID))
response.JSON(ctx, w, http.StatusCreated, item) response.JSON(ctx, w, http.StatusCreated, item)
} }
@@ -302,7 +308,7 @@ func (h *ListHandler) DeleteListItem(w http.ResponseWriter, r *http.Request) {
return return
} }
slog.InfoContext(ctx, "deleted list item successfully", slog.Any("list_item_id", listItemID)) slog.InfoContext(ctx, "deleted list item successfully", slog.String("list_item_id", listItemID))
response.Status(w, http.StatusNoContent) response.Status(w, http.StatusNoContent)
} }
@@ -343,7 +349,7 @@ func (h *ListHandler) UpdateListItem(w http.ResponseWriter, r *http.Request) {
return return
} }
slog.InfoContext(ctx, "updated list item successfully", slog.Any("list_item_id", payload.ListItemID)) slog.InfoContext(ctx, "updated list item successfully", slog.String("list_item_id", payload.ListItemID))
response.Status(w, http.StatusNoContent) response.Status(w, http.StatusNoContent)
} }
@@ -393,7 +399,7 @@ func (h *ListHandler) SetListItemCompleted(w http.ResponseWriter, r *http.Reques
return return
} }
slog.InfoContext(ctx, "updated list item completed successful", slog.Any("list_item_id", listItemID)) slog.InfoContext(ctx, "updated list item completed successful", slog.String("list_item_id", listItemID))
response.Status(w, http.StatusNoContent) response.Status(w, http.StatusNoContent)
} }
+1 -1
View File
@@ -9,7 +9,7 @@ import (
) )
var ( var (
ErrUserIDMissing = errors.New("user id is missing") ErrUserIDMissing = errors.New("user id is required")
ErrEmailMissing = errors.New("email is required") ErrEmailMissing = errors.New("email is required")
ErrNameMissing = errors.New("name is required") ErrNameMissing = errors.New("name is required")
ErrPasswordMissing = errors.New("password is required") ErrPasswordMissing = errors.New("password is required")
-1
View File
@@ -93,7 +93,6 @@ func (r *ListRepo) GetLists(ctx context.Context, userID string) ([]domain.List,
} }
return lists, nil return lists, nil
} }
func (r *ListRepo) AddUserToList(ctx context.Context, listID string, userID string) error { func (r *ListRepo) AddUserToList(ctx context.Context, listID string, userID string) error {