scouting: Add more debug logging when stats get submitted

We're getting reports of folks not being able to submit data scouting
because of duplication errors. Looking at the database, there are some
actions present for a team's match, but no corresponding stats.
Subsequent attempts to submit the data will fail because the actions
are already there.

What we need to figure out is what error is happening the first time
around. I.e. what happens on the initial submission attempt? This
patch aims to help us find out by logging more information.

Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: Iae7c3bd5237b434126cc55c04c786d69c9d76c6a
diff --git a/scouting/webserver/requests/requests.go b/scouting/webserver/requests/requests.go
index 18d7ed5..0367ff2 100644
--- a/scouting/webserver/requests/requests.go
+++ b/scouting/webserver/requests/requests.go
@@ -1142,16 +1142,18 @@
 
 	requestBytes, err := io.ReadAll(req.Body)
 	if err != nil {
+		log.Println("Failed to receive submission request from", username)
 		respondWithError(w, http.StatusBadRequest, fmt.Sprint("Failed to read request bytes:", err))
 		return
 	}
 
 	request, success := parseRequest(w, requestBytes, "Submit2024Actions", submit_2024_actions.GetRootAsSubmit2024Actions)
 	if !success {
+		log.Println("Failed to parse submission request from", username)
 		return
 	}
 
-	log.Println("Got actions for match", request.MatchNumber(), "team", string(request.TeamNumber()), "from", username)
+	log.Println("Got actions for match", request.MatchNumber(), "team", string(request.TeamNumber()), "type", string(request.CompType()), "from", username)
 
 	for i := 0; i < request.ActionsListLength(); i++ {
 
@@ -1172,6 +1174,7 @@
 
 		// Do some error checking.
 		if action.Timestamp() < 0 {
+			log.Println("Got action with invalid timestamp (", action.Timestamp(), ") from", username)
 			respondWithError(w, http.StatusBadRequest, fmt.Sprint(
 				"Invalid timestamp field value of ", action.Timestamp()))
 			return
@@ -1179,6 +1182,7 @@
 
 		err = handler.db.AddAction(dbAction)
 		if err != nil {
+			log.Println("Failed to add action from", username, "to the database:", err)
 			respondWithError(w, http.StatusInternalServerError, fmt.Sprint("Failed to add action to database: ", err))
 			return
 		}
@@ -1186,6 +1190,7 @@
 
 	stats, err := ConvertActionsToStat2024(request)
 	if err != nil {
+		log.Println("Failed to add action from", username, "to the database:", err)
 		respondWithError(w, http.StatusInternalServerError, fmt.Sprint("Failed to convert actions to stats: ", err))
 		return
 	}
@@ -1194,6 +1199,7 @@
 
 	err = handler.db.AddToStats2024(stats)
 	if err != nil {
+		log.Println("Failed to submit stats from", username, "to the database:", err)
 		respondWithError(w, http.StatusInternalServerError, fmt.Sprint("Failed to submit stats2024: ", stats, ": ", err))
 		return
 	}
@@ -1201,6 +1207,8 @@
 	builder := flatbuffers.NewBuilder(50 * 1024)
 	builder.Finish((&Submit2024ActionsResponseT{}).Pack(builder))
 	w.Write(builder.FinishedBytes())
+
+	log.Println("Successfully added stats from", username)
 }
 
 type Delete2024DataScoutingHandler struct {