Skip to content

Commit

Permalink
add detailed logging for one channel
Browse files Browse the repository at this point in the history
  • Loading branch information
nikooo777 committed Nov 27, 2024
1 parent 46c12b9 commit 5e84716
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions server/services/v1/comments/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package comments

import (
"database/sql"
"encoding/json"
"fmt"
"net/http"
"os"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5e84716

Please sign in to comment.