Tidy VSTP logging
All checks were successful
Go Test / test (push) Successful in 52s

This commit is contained in:
Fred Boniface 2024-04-26 20:48:17 +01:00
parent b2c9910856
commit 7bae3575d5
2 changed files with 4 additions and 10 deletions

View File

@ -8,12 +8,8 @@ import (
"go.uber.org/zap"
)
var count uint64 = 0
func handle(msg *stomp.Message) {
start := time.Now()
count++
log.Info("Message received", zap.Uint64("total since startup", count))
schedule, err := unmarshalData(msg.Body)
if err != nil {
log.Error("Error unmarshalling VSTP Message", zap.Error(err))
@ -28,6 +24,6 @@ func handle(msg *stomp.Message) {
log.Error("Error processing VSTP Schedule", zap.Error(err))
}
end := time.Now()
duration := start.Sub(end)
duration := end.Sub(start)
log.Info("Message processed", zap.Duration("processing-time", duration))
}

View File

@ -1,7 +1,6 @@
package vstp
import (
"fmt"
"time"
"git.fjla.uk/owlboard/timetable-mgr/log"
@ -46,14 +45,13 @@ func Subscribe() {
for {
msg := <-sub.C
if msg.Err != nil {
log.Error("STOMP Message Error", zap.Error(msg.Err))
log.Error("VSTP Message Error", zap.Error(msg.Err))
} else {
if msg != nil {
log.Info("STOMP Message Received")
fmt.Println(string(msg.Body))
log.Info("VSTP Message Received")
handle(msg)
} else {
log.Info("STOMP Message Empty")
log.Info("VSTP Message Empty")
}
}
}