Skip to content

Commit

Permalink
zap ctx
Browse files Browse the repository at this point in the history
  • Loading branch information
khushijain21 committed Jun 3, 2024
1 parent e174da6 commit 23ab6d3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
6 changes: 1 addition & 5 deletions bridges/otelzap/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func NewCore(name string, opts ...Option) *Core {
cfg := newConfig(opts)
return &Core{
logger: cfg.logger(name),
ctx: context.Background(),
}
}

Expand All @@ -120,11 +121,6 @@ func (o *Core) With(fields []zapcore.Field) zapcore.Core {
return cloned
}

// used in test
func (o *Core) getctx() context.Context {
return o.ctx
}

func (o *Core) clone() *Core {
return &Core{
logger: o.logger,
Expand Down
11 changes: 0 additions & 11 deletions bridges/otelzap/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,6 @@ func TestCore(t *testing.T) {

rec.Reset()

t.Run("WriteContext", func(t *testing.T) {
logger.Info(testMessage, zap.Any("context", context.Background()))
got := rec.Result()[0].Records[0]
assert.Equal(t, testMessage, got.Body().AsString())
assert.Equal(t, log.SeverityInfo, got.Severity())
assert.Equal(t, 0, got.AttributesLen())
assert.Equal(t, zc.getctx(), context.Background())
})

rec.Reset()

// test child logger with accumulated fields
t.Run("With", func(t *testing.T) {
testCases := [][]string{{"test1", "value1"}, {"test2", "value2"}}
Expand Down

0 comments on commit 23ab6d3

Please sign in to comment.