From 5e8471655b7a28ced8be4b21a138d6990d969541 Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Wed, 27 Nov 2024 20:17:50 +0100 Subject: [PATCH] add detailed logging for one channel --- server/services/v1/comments/create.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/server/services/v1/comments/create.go b/server/services/v1/comments/create.go index 22f0b50..97d6126 100644 --- a/server/services/v1/comments/create.go +++ b/server/services/v1/comments/create.go @@ -2,8 +2,10 @@ package comments import ( "database/sql" + "encoding/json" "fmt" "net/http" + "os" "strconv" "strings" "time" @@ -37,12 +39,30 @@ import ( "github.com/volatiletech/sqlboiler/v4/queries/qm" ) +var specialLogFile *os.File + +func init() { + var err error + specialLogFile, err = os.OpenFile("special.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + logrus.Fatal(err) + } +} func create(_ *http.Request, args *commentapi.CreateArgs, reply *commentapi.CreateResponse) error { err := v.ValidateStruct(args, v.Field(&args.ClaimID, v.Required)) if err != nil { return api.StatusError{Err: errors.Err(err), Status: http.StatusBadRequest} } + //log what this special commenter is doing to find the bug + if args.ChannelID == "ccf4e035d8164d8a6540d96d1a689a4f068b6bc7" { + stuffToLog, err := json.Marshal(args) + stuffToLog = append(stuffToLog, '\n') + if err == nil { + _, _ = specialLogFile.Write(stuffToLog) + } + + } channel, err := helper.FindOrCreateChannel(args.ChannelID, args.ChannelName) if err != nil { return errors.Err(err)