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 { ...@@ -67,6 +67,14 @@ func (b *Builder) WithError(err error) *Builder {
return b return b
} }
func Debug(args ...interface{}) {
NewBuilder().Debug(args...)
}
func (b *Builder) Debug(args ...interface{}) {
b.entry.Debug(args...)
}
func Info(args ...interface{}) { func Info(args ...interface{}) {
NewBuilder().Info(args...) NewBuilder().Info(args...)
} }
......
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"net/http/httptest" "net/http/httptest"
"testing" "testing"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
...@@ -14,6 +15,7 @@ func captureLogs(b *Builder, testFn func()) string { ...@@ -14,6 +15,7 @@ func captureLogs(b *Builder, testFn func()) string {
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
logger := b.entry.Logger logger := b.entry.Logger
logger.SetLevel(logrus.DebugLevel)
oldOut := logger.Out oldOut := logger.Out
logger.Out = buf logger.Out = buf
defer func() { defer func() {
...@@ -25,6 +27,15 @@ func captureLogs(b *Builder, testFn func()) string { ...@@ -25,6 +27,15 @@ func captureLogs(b *Builder, testFn func()) string {
return buf.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) { func TestLogInfo(t *testing.T) {
b := NewBuilder() b := NewBuilder()
logLine := captureLogs(b, func() { 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