(t *testing.T)
| 41 | } |
| 42 | |
| 43 | func TestCtxDisabled(t *testing.T) { |
| 44 | dl := New(io.Discard).Level(Disabled) |
| 45 | ctx := dl.WithContext(context.Background()) |
| 46 | if ctx != context.Background() { |
| 47 | t.Error("WithContext stored a disabled logger") |
| 48 | } |
| 49 | |
| 50 | l := New(io.Discard).With().Str("foo", "bar").Logger() |
| 51 | ctx = l.WithContext(ctx) |
| 52 | if !reflect.DeepEqual(Ctx(ctx), &l) { |
| 53 | t.Error("WithContext did not store logger") |
| 54 | } |
| 55 | |
| 56 | l.UpdateContext(func(c Context) Context { |
| 57 | return c.Str("bar", "baz") |
| 58 | }) |
| 59 | ctx = l.WithContext(ctx) |
| 60 | if !reflect.DeepEqual(Ctx(ctx), &l) { |
| 61 | t.Error("WithContext did not store updated logger") |
| 62 | } |
| 63 | |
| 64 | l = l.Level(DebugLevel) |
| 65 | ctx = l.WithContext(ctx) |
| 66 | if !reflect.DeepEqual(Ctx(ctx), &l) { |
| 67 | t.Error("WithContext did not store copied logger") |
| 68 | } |
| 69 | |
| 70 | ctx = dl.WithContext(ctx) |
| 71 | if !reflect.DeepEqual(Ctx(ctx), &dl) { |
| 72 | t.Error("WithContext did not override logger with a disabled logger") |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | type logObjectMarshalerImpl struct { |
| 77 | name string |
nothing calls this directly
no test coverage detected