@@ 0,0 1,28 @@
+package model
+
+import (
+ "fmt"
+ "strings"
+)
+
+func (input UserInput) String() string {
+ var e []string
+
+ if input.Avatar != nil {
+ e = append(e, "Avatar")
+ }
+
+ if input.Elo != nil {
+ e = append(e, fmt.Sprintf("Elo %d", *input.Elo))
+ }
+
+ if input.Name != nil {
+ e = append(e, fmt.Sprintf("Name %q", *input.Name))
+ }
+
+ if input.TeamspeakID != nil {
+ e = append(e, fmt.Sprintf("TeamspeakID %q", *input.TeamspeakID))
+ }
+
+ return strings.Join(e, ", ")
+}
@@ 67,6 67,7 @@ func (r *mutationResolver) CreateUser(ctx context.Context, input model.NewUser)
return "", database.CheckErrorCode(err)
}
+ r.Logger.Infof("Created user %q (Elo: %d).", input.SteamID, elo.Elo)
return "Created", nil
}
@@ 74,7 75,13 @@ func (r *mutationResolver) CreateUser(ctx context.Context, input model.NewUser)
func (r *mutationResolver) DeleteUser(ctx context.Context, id int) (string, error) {
query := `DELETE FROM "User" WHERE id = $1`
_, err := r.DB.DB.Exec(query, id)
- return "Deleted", err
+
+ if err != nil {
+ return "", err
+ }
+
+ r.Logger.Infof("Deleted user with ID %d.", id)
+ return "Deleted", nil
}
// UpdateUser is the resolver for the updateUser field.
@@ 146,6 153,7 @@ func (r *mutationResolver) UpdateUser(ctx context.Context, id int, input model.U
return nil, err
}
+ r.Logger.Infof("Updated user with ID %d: %v", id, input)
return &user, nil
}
@@ 406,6 414,8 @@ func (r *mutationResolver) FinishMatch(ctx context.Context, winner string) (stri
if err != nil {
return "FinishFail", err
}
+ r.Logger.Infof("%s won the match.", winner)
+ r.Logger.Debugf("Team 1 got %d Elo, Team 2 got %d Elo.", delta1, delta2)
return "FinishSuccess", nil
}