k3s/pkg/dqlite/log.go

28 lines
514 B
Go
Raw Normal View History

2019-10-31 02:05:40 +00:00
package dqlite
import (
2019-11-11 22:18:43 +00:00
"strings"
2019-10-31 02:05:40 +00:00
"github.com/canonical/go-dqlite/client"
"github.com/sirupsen/logrus"
)
func log() client.LogFunc {
return func(level client.LogLevel, s string, i ...interface{}) {
switch level {
case client.LogDebug:
logrus.Debugf(s, i...)
case client.LogError:
logrus.Errorf(s, i...)
case client.LogInfo:
2019-11-11 22:18:43 +00:00
if strings.HasPrefix(s, "connected") {
logrus.Debugf(s, i...)
} else {
logrus.Infof(s, i...)
}
2019-10-31 02:05:40 +00:00
case client.LogWarn:
logrus.Warnf(s, i...)
}
}
}