We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2a240b1 commit ad13956Copy full SHA for ad13956
core.go
@@ -208,6 +208,11 @@ func (l *Core) IsDebug() bool {
208
return l.IsEnabled(DebugLevel)
209
}
210
211
+// IsDebug returns true if INF level is enabled
212
+func (l *Core) IsInfo() bool {
213
+ return l.IsEnabled(InfoLevel)
214
+}
215
+
216
// With returns a new Logger with some context baked in. All entries
217
// logged with the new logger will include this context.
218
//
core_test.go
@@ -20,3 +20,31 @@ func TestSweetenFields(t *testing.T) {
20
fields = c.sweetenFields([]interface{}{err})
21
assert.Equal(t, []zap.Field{zap.NamedError("error", err)}, fields)
22
23
24
+func TestCore_IsDebug(t *testing.T) {
25
+ f := NewFactory()
26
+ f.SetDefaultLevel(InfoLevel)
27
28
+ l := f.NewLogger("asdf")
29
+ assert.False(t, l.IsDebug())
30
+ f.SetDefaultLevel(DebugLevel)
31
+ assert.True(t, l.IsDebug())
32
+ f.SetDefaultLevel(ErrorLevel)
33
34
+ f.SetLevel("asdf", DebugLevel)
35
36
37
38
+func TestCore_IsInfo(t *testing.T) {
39
40
41
42
43
+ assert.False(t, l.IsInfo())
44
45
+ assert.True(t, l.IsInfo())
46
47
48
49
50
log.go
@@ -20,6 +20,7 @@ type (
Error(msg string, args ...interface{})
IsDebug() bool
+ IsInfo() bool
// With creates a new Logger with some context already attached. All
// entries logged with the child logger will include this context.
0 commit comments