Skip to content

Commit adf46dd

Browse files
committed
fix test
1 parent bff6e2b commit adf46dd

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

pkg/loop/logger.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ func NewOtelLogger(otelLogger otellog.Logger) (logger.Logger, error) {
195195
if err != nil {
196196
return nil, err
197197
}
198-
return logger.NewWithCores(primaryCore, otelzap.NewCore(otelLogger)), nil
198+
// set debug level from primaryCore to match otelzap.NewCore
199+
return logger.NewWithCores(primaryCore, otelzap.NewCore(otelLogger, otelzap.WithLevel(zapcore.DebugLevel))), nil
199200
}
200201

201202
// onceValue returns a function that invokes f only once and returns the value

pkg/loop/logger_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import (
55
"sync"
66
"testing"
77

8-
"github.com/smartcontractkit/chainlink-common/pkg/logger"
9-
"github.com/smartcontractkit/chainlink-common/pkg/logger/otelzap"
108
"github.com/stretchr/testify/assert"
119
sdklog "go.opentelemetry.io/otel/sdk/log"
10+
11+
"github.com/smartcontractkit/chainlink-common/pkg/logger"
12+
"github.com/smartcontractkit/chainlink-common/pkg/logger/otelzap"
1213
)
1314

1415
func Test_removeArg(t *testing.T) {
@@ -80,6 +81,11 @@ func TestNewOtelLogger(t *testing.T) {
8081

8182
tt.logFn(lggr)
8283

84+
// Force flush the logger provider to ensure records are exported
85+
if err := lp.ForceFlush(context.Background()); err != nil {
86+
t.Fatalf("ForceFlush error: %v", err)
87+
}
88+
8389
if len(exp.records) != 1 {
8490
t.Fatalf("expected 1 exported record, got %d", len(exp.records))
8591
}

0 commit comments

Comments
 (0)