log logger's errors (Refs #29)

This commit is contained in:
Anton Kaliaev
2017-11-06 14:18:42 -05:00
parent ac0cf0b2e2
commit 4b989151ed
2 changed files with 26 additions and 3 deletions

View File

@ -1,12 +1,26 @@
package log_test
import (
"bytes"
"io/ioutil"
"strings"
"testing"
"github.com/go-logfmt/logfmt"
"github.com/tendermint/tmlibs/log"
)
func TestLoggerLogsItsErrors(t *testing.T) {
var buf bytes.Buffer
logger := log.NewTMLogger(&buf)
logger.Info("foo", "baz baz", "bar")
msg := strings.TrimSpace(buf.String())
if !strings.Contains(msg, logfmt.ErrInvalidKey.Error()) {
t.Errorf("Expected logger msg to contain ErrInvalidKey, got %s", msg)
}
}
func BenchmarkTMLoggerSimple(b *testing.B) {
benchmarkRunner(b, log.NewTMLogger(ioutil.Discard), baseInfoMessage)
}