Skip to content

Commit

Permalink
Add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jrouzierinverse committed Dec 11, 2024
1 parent 5cd3017 commit 7dc61eb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions go/cron/kafka_submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"sync"
"time"

"github.com/inverse-inc/go-utils/log"
"github.com/segmentio/kafka-go"
"github.com/segmentio/kafka-go/compress"
"github.com/segmentio/kafka-go/sasl/plain"
Expand Down Expand Up @@ -117,13 +118,19 @@ func (s *KafkaSubmiter) send(events []*NetworkEvent) {
filteredEvents = events
}

ctx := context.Background()
messages := make([]kafka.Message, 0, len(filteredEvents))
for i := 0; i < len(filteredEvents); i++ {
data, err := json.Marshal(events[i])
if err != nil {
//TODO log error
continue
}
log.LogInfof(
ctx,
"Sending SrcIp: %s, DstIp: %s, DstPort: %d, Direction: %s",
events[i].SourceIp, events[i].DestIp, events[i].DestPort, events[i].Direction,
)
messages = append(messages, kafka.Message{Value: data})
}

Expand Down

0 comments on commit 7dc61eb

Please sign in to comment.