Adapt to logging changes in weaveworks/mesh

This commit is contained in:
Bryan Boreham committed 2016-04-04 16:01:58 +01:00
1 parent 00fe47ba62
commit c38dcb1d73
2 files changed
+22 -1

No files matched your search

+21
View File
@@ -3,6 +3,7 @@ package common
import (
"bytes"
"fmt"
"log"
"strings"
"github.com/Sirupsen/logrus"
@@ -64,3 +65,23 @@ func CheckWarn(e error) {
Log.Warnln(e)
}
}
// Adaptor type to go from Logrus to something expecting a standard library log.Logger
type logLogger struct {
logger *logrus.Logger
}
// io.Writer interface
func (l logLogger) Write(p []byte) (n int, err error) {
ln := len(p)
// Strip a trailing newline, because logrus formatter adds one
if ln > 0 && p[ln-1] == '\n' {
p = p[:ln-1]
}
l.logger.Info(string(p))
return ln, nil
}
func LogLogger() *log.Logger {
return log.New(logLogger{Log}, "", 0)
}