package vstp import ( "encoding/json" "fmt" "io/ioutil" "time" //"git.fjla.uk/owlboard/go-types/pkg/database" "git.fjla.uk/owlboard/mq-client/log" "github.com/go-stomp/stomp/v3" ) var count uint64 = 0 func handle(msg *stomp.Message) { count++ log.Msg.Info("Message count: " + fmt.Sprint(count)) schedule := unmarshalData(string(msg.Body)) processEntryType(schedule) saveToFile(schedule, "transformed") } func saveToFile(msg any, suffix string) { timestamp := time.Now().Format("2006-01-02T15:04:05") path := fmt.Sprintf("message-logs/%s-%s.json", timestamp, suffix) prettyJSON, err := json.MarshalIndent(msg, "", " ") if err != nil { log.Msg.Error("Error marshaling data to JSON: " + err.Error()) return } err = ioutil.WriteFile(path, prettyJSON, 0644) if err != nil { log.Msg.Error("Error saving message: " + err.Error()) return } log.Msg.Info("Saved message to: " + path) }