Skip to content

Commit 5e2e190

Browse files
authored
Lazy Acker print actions as string so it indeed prints them (#1950)
1 parent 960a5d2 commit 5e2e190

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

internal/pkg/fleetapi/acker/lazy/lazy_acker.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,18 @@ func (f *Acker) Commit(ctx context.Context) (err error) {
8080
actions := f.queue
8181
f.queue = make([]fleetapi.Action, 0)
8282

83-
f.log.Debugf("lazy acker: ackbatch: %#v", actions)
83+
f.log.Debugf("lazy acker: ack batch: %s", actions)
8484
var resp *fleetapi.AckResponse
8585
resp, err = f.acker.AckBatch(ctx, actions)
8686

8787
// If request failed enqueue all actions with retrier if it is set
8888
if err != nil {
8989
if f.retrier != nil {
90-
f.log.Errorf("lazy acker: failed ack batch, enqueue for retry: %#v", actions)
90+
f.log.Errorf("lazy acker: failed ack batch, enqueue for retry: %s", actions)
9191
f.retrier.Enqueue(actions)
9292
return nil
9393
}
94-
f.log.Errorf("lazy acker: failed ack batch, no retrier set, fail with err: %v", err)
94+
f.log.Errorf("lazy acker: failed ack batch, no retrier set, fail with err: %s", err)
9595
return err
9696
}
9797

@@ -107,7 +107,7 @@ func (f *Acker) Commit(ctx context.Context) (err error) {
107107
}
108108
}
109109
if len(failed) > 0 {
110-
f.log.Infof("lazy acker: partially failed ack batch, enqueue for retry: %#v", failed)
110+
f.log.Infof("lazy acker: partially failed ack batch, enqueue for retry: %s", failed)
111111
f.retrier.Enqueue(failed)
112112
}
113113
}

internal/pkg/fleetapi/acker/lazy/lazy_acker_test.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
"github.com/google/go-cmp/cmp"
1414

15+
"github.com/elastic/elastic-agent-libs/logp"
1516
"github.com/elastic/elastic-agent/internal/pkg/fleetapi"
1617
"github.com/elastic/elastic-agent/pkg/core/logger"
1718
)
@@ -82,7 +83,11 @@ func TestLazyAcker(t *testing.T) {
8283
ctx, cn := context.WithCancel(context.Background())
8384
defer cn()
8485

85-
log, _ := logger.New("", false)
86+
cfg := logger.DefaultLoggingConfig()
87+
cfg.Level = logp.DebugLevel
88+
// cfg.ToFiles = false
89+
cfg.ToStderr = true
90+
log, _ := logger.NewFromConfig("", cfg, true)
8691

8792
// Tests
8893
tests := []struct {

0 commit comments

Comments
 (0)