Skip to content

Commit 5e83aa5

Browse files
authored
Merge pull request #180 from moov-io/add-debug-log-level
add debug level
2 parents 2aae7b7 + b220f2c commit 5e83aa5

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

log/logger.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ type Logger interface {
44
Set(key string, value Valuer) Logger
55
With(ctxs ...Context) Logger
66

7+
Debug() Logger
78
Info() Logger
89
Warn() Logger
910
Error() Logger

log/logger_impl.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ func (l *logger) With(ctxs ...Context) Logger {
7373
}
7474
}
7575

76+
func (l *logger) Debug() Logger {
77+
return l.With(Debug)
78+
}
79+
7680
func (l *logger) Info() Logger {
7781
return l.With(Info)
7882
}

log/logger_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ func Test_ReplaceContextValue(t *testing.T) {
166166
a.Contains(buffer.String(), "level=warn")
167167
}
168168

169+
func Test_Debug(t *testing.T) {
170+
a, buffer, log := Setup(t)
171+
172+
log.Debug().Logf("message")
173+
174+
a.Contains(buffer.String(), "level=debug")
175+
}
176+
169177
func Test_Info(t *testing.T) {
170178
a, buffer, log := Setup(t)
171179

log/model_levels.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ package log
33
// Level just wraps a string to be able to add Context specific to log levels
44
type Level string
55

6+
// Info is sets level=info in the log output
7+
const Debug = Level("debug")
8+
69
// Info is sets level=info in the log output
710
const Info = Level("info")
811

0 commit comments

Comments
 (0)