From 3c143f5d6070f28e28e49e774f217b0c5a86f1b0 Mon Sep 17 00:00:00 2001 From: Kevin Franklin Kim Date: Thu, 30 May 2024 15:07:08 +0200 Subject: [PATCH] feat: switch log level --- integration/loki/loki.go | 2 +- integration/watermill/gtag/subscriber.go | 6 +++--- integration/watermill/mpv2/subscriber.go | 6 +++--- pkg/utils/batch.go | 5 ----- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/integration/loki/loki.go b/integration/loki/loki.go index 95253cf..48902c8 100644 --- a/integration/loki/loki.go +++ b/integration/loki/loki.go @@ -182,7 +182,7 @@ func (l *Loki) Stop() { // ------------------------------------------------------------------------------------------------ func (l *Loki) process(entries []logproto.Entry) { - l.l.Info("processing entries batch", zap.Int("num", len(entries))) + l.l.Debug("processing entries batch", zap.Int("num", len(entries))) labels := model.LabelSet{ "name": "events", diff --git a/integration/watermill/gtag/subscriber.go b/integration/watermill/gtag/subscriber.go index 2129c66..163a038 100644 --- a/integration/watermill/gtag/subscriber.go +++ b/integration/watermill/gtag/subscriber.go @@ -166,13 +166,13 @@ func (s *Subscriber) handle(l *zap.Logger, r *http.Request, payload *gtag.Payloa // wait for ACK select { case <-msg.Acked(): - l.Info("message acked") + l.Debug("message acked") return nil case <-msg.Nacked(): - l.Info("message nacked") + l.Debug("message nacked") return ErrMessageNacked case <-r.Context().Done(): - l.Info("message cancled") + l.Debug("message cancled") return ErrContextCanceled } } diff --git a/integration/watermill/mpv2/subscriber.go b/integration/watermill/mpv2/subscriber.go index 1cc998c..195a87c 100644 --- a/integration/watermill/mpv2/subscriber.go +++ b/integration/watermill/mpv2/subscriber.go @@ -139,13 +139,13 @@ func (s *Subscriber) handle(l *zap.Logger, r *http.Request, payload *mpv2.Payloa // wait for ACK select { case <-msg.Acked(): - l.Info("message acked") + l.Debug("message acked") return nil case <-msg.Nacked(): - l.Info("message nacked") + l.Debug("message nacked") return ErrMessageNacked case <-r.Context().Done(): - l.Info("message cancled") + l.Debug("message cancled") return ErrContextCanceled } } diff --git a/pkg/utils/batch.go b/pkg/utils/batch.go index 7777d9b..66f6847 100644 --- a/pkg/utils/batch.go +++ b/pkg/utils/batch.go @@ -2,14 +2,12 @@ package utils import ( "context" - "fmt" ) // Batch reads from a channel and calls fn with a slice of batchSize. func Batch[T any](ctx context.Context, ch <-chan T, batchSize int, fn func([]T)) { if batchSize <= 1 { // sanity check, for v := range ch { - fmt.Println("<< 1") fn([]T{v}) } return @@ -21,20 +19,17 @@ func Batch[T any](ctx context.Context, ch <-chan T, batchSize int, fn func([]T)) select { case <-ctx.Done(): if len(batch) > 0 { - fmt.Println("<< 2") fn(batch) } return case v, ok := <-ch: if !ok { // closed - fmt.Println("<< 3") fn(batch) return } batch = append(batch, v) if len(batch) == batchSize { // full - fmt.Println("<< 4") fn(batch) batch = make([]T, 0, batchSize) // reset }