From c52f4b043dab3a39097f158f59250b6b1a594d6a Mon Sep 17 00:00:00 2001 From: NicoMen Date: Fri, 14 Sep 2018 13:34:03 +0200 Subject: [PATCH] =?UTF-8?q?Add=20interface=20to=20Tr=C3=A6fik=20logger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- log/logger.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/log/logger.go b/log/logger.go index ed5270775..768352520 100644 --- a/log/logger.go +++ b/log/logger.go @@ -10,8 +10,14 @@ import ( "github.com/sirupsen/logrus" ) +// Logger allows overriding the logrus logger behavior +type Logger interface { + logrus.FieldLogger + WriterLevel(logrus.Level) *io.PipeWriter +} + var ( - logger *logrus.Entry + logger Logger logFilePath string logFile *os.File ) @@ -41,6 +47,11 @@ func SetLevel(level logrus.Level) { logrus.SetLevel(level) } +// SetLogger sets the logger. +func SetLogger(l Logger) { + logger = l +} + // GetLevel returns the standard logger level. func GetLevel() logrus.Level { return logrus.GetLevel()