浏览代码

chore: add additional logs

master
Blaz Smehov 1周前
父节点
当前提交
c401ba3af3
共有 1 个文件被更改,包括 8 次插入2 次删除
  1. +8
    -2
      cmd/location/main.go

+ 8
- 2
cmd/location/main.go 查看文件

@@ -51,6 +51,7 @@ func main() {
switch msg.Method {
case "POST":
id := msg.Beacon.ID
fmt.Println("Beacon added to lookup: ", id)
appState.AddBeaconToLookup(id)
case "DELETE":
fmt.Println("Incoming delete message")
@@ -76,6 +77,7 @@ func getLikelyLocations(appState *appcontext.AppState, writer *kafka.Writer) {
mSize := len(beacon.BeaconMetrics)

if (int64(time.Now().Unix()) - (beacon.BeaconMetrics[mSize-1].Timestamp)) > settings.LastSeenThreshold {
fmt.Println("Beacon is too old")
continue
}

@@ -109,7 +111,8 @@ func getLikelyLocations(appState *appcontext.AppState, writer *kafka.Writer) {
if beacon.LocationConfidence == settings.LocationConfidence && beacon.PreviousConfidentLocation != bestLocName {
beacon.LocationConfidence = 0

// Who do I need this if I am sending entire structure anyways? who knows
// Why do I need this if I am sending entire structure anyways? who knows
fmt.Println("this is called")
js, err := json.Marshal(model.LocationChange{
Method: "LocationChange",
BeaconRef: beacon,
@@ -120,6 +123,7 @@ func getLikelyLocations(appState *appcontext.AppState, writer *kafka.Writer) {
})

if err != nil {
fmt.Println("This error happens: ", err)
beacon.PreviousConfidentLocation = bestLocName
beacon.PreviousLocation = bestLocName
appState.UpdateBeacon(beacon.ID, beacon)
@@ -141,6 +145,7 @@ func getLikelyLocations(appState *appcontext.AppState, writer *kafka.Writer) {

js, err := json.Marshal(r)
if err != nil {
fmt.Println("Error in marshaling location: ", err)
continue
}

@@ -150,7 +155,7 @@ func getLikelyLocations(appState *appcontext.AppState, writer *kafka.Writer) {

err = writer.WriteMessages(context.Background(), msg)
if err != nil {
fmt.Println("Error in sending Kafka message")
fmt.Println("Error in sending Kafka message: ", err)
}
}
}
@@ -168,6 +173,7 @@ func assignBeaconToList(adv model.BeaconAdvertisement, appState *appcontext.AppS
settings := appState.GetSettingsValue()

if settings.RSSIEnforceThreshold && (int64(adv.RSSI) < settings.RSSIMinThreshold) {
fmt.Println("Settings returns")
return
}



正在加载...
取消
保存