Commit b5438e74 authored by Mike Kozono's avatar Mike Kozono

Add Debug level logging to Workhorse

parent dc6a267a
......@@ -67,6 +67,14 @@ func (b *Builder) WithError(err error) *Builder {
return b
}
func Debug(args ...interface{}) {
NewBuilder().Debug(args...)
}
func (b *Builder) Debug(args ...interface{}) {
b.entry.Debug(args...)
}
func Info(args ...interface{}) {
NewBuilder().Info(args...)
}
......
......@@ -7,6 +7,7 @@ import (
"net/http/httptest"
"testing"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
)
......@@ -14,6 +15,7 @@ func captureLogs(b *Builder, testFn func()) string {
buf := &bytes.Buffer{}
logger := b.entry.Logger
logger.SetLevel(logrus.DebugLevel)
oldOut := logger.Out
logger.Out = buf
defer func() {
......@@ -25,6 +27,15 @@ func captureLogs(b *Builder, testFn func()) string {
return buf.String()
}
func TestLogDebug(t *testing.T) {
b := NewBuilder()
logLine := captureLogs(b, func() {
b.Debug("an observation")
})
require.Regexp(t, `level=debug msg="an observation"`, logLine)
}
func TestLogInfo(t *testing.T) {
b := NewBuilder()
logLine := captureLogs(b, func() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment