| 86 | } |
| 87 | |
| 88 | func TestLoggerLevel(t *testing.T) { |
| 89 | levels := []zapcore.Level{ |
| 90 | DebugLevel, |
| 91 | InfoLevel, |
| 92 | WarnLevel, |
| 93 | ErrorLevel, |
| 94 | DPanicLevel, |
| 95 | PanicLevel, |
| 96 | FatalLevel, |
| 97 | } |
| 98 | |
| 99 | for _, lvl := range levels { |
| 100 | lvl := lvl |
| 101 | t.Run(lvl.String(), func(t *testing.T) { |
| 102 | t.Parallel() |
| 103 | |
| 104 | core, _ := observer.New(lvl) |
| 105 | log := New(core) |
| 106 | assert.Equal(t, lvl, log.Level()) |
| 107 | }) |
| 108 | } |
| 109 | |
| 110 | t.Run("Nop", func(t *testing.T) { |
| 111 | assert.Equal(t, zapcore.InvalidLevel, NewNop().Level()) |
| 112 | }) |
| 113 | } |
| 114 | |
| 115 | func TestLoggerInitialFields(t *testing.T) { |
| 116 | fieldOpts := opts(Fields(Int("foo", 42), String("bar", "baz"))) |