2
0

Add log adapters for testing and log15

Make LogLevel a type for Stringer interface.
This commit is contained in:
Jack Christensen
2017-04-29 20:33:52 -05:00
parent 353ca7c5c7
commit 855b735eae
8 changed files with 103 additions and 30 deletions
+25
View File
@@ -0,0 +1,25 @@
// Package testingadapter provides a logger that writes to a test or benchmark
// log.
package testingadapter
import (
"github.com/jackc/pgx"
)
// TestingLogger interface defines the subset of testing.TB methods used by this
// adapter.
type TestingLogger interface {
Log(args ...interface{})
}
type Logger struct {
l TestingLogger
}
func NewLogger(l TestingLogger) *Logger {
return &Logger{l: l}
}
func (l *Logger) Log(level pgx.LogLevel, msg string, ctx ...interface{}) {
l.l.Log(level, msg, ctx)
}