From e4c6c25a3fcf884b43369a60818ff5fa56a30c66 Mon Sep 17 00:00:00 2001 From: Malyue <86157286+Malyue@users.noreply.github.com> Date: Fri, 12 Jan 2024 10:00:02 +0800 Subject: [PATCH] fix: add logs methods (#311) * fix: add log methods * delete some method --- base/logs/logrusx/log.go | 6 ++++++ base/logs/logs.go | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/base/logs/logrusx/log.go b/base/logs/logrusx/log.go index ae36b3ad..71a8658b 100644 --- a/base/logs/logrusx/log.go +++ b/base/logs/logrusx/log.go @@ -15,6 +15,8 @@ package logrusx import ( + "io" + "github.com/sirupsen/logrus" "github.com/erda-project/erda-infra/base/logs" @@ -59,6 +61,10 @@ func (l *Logger) SetLevel(lvl string) error { return nil } +func (l *Logger) SetOutput(output io.Writer) { + l.Logger.SetOutput(output) +} + func processOptions(logr *logrus.Logger, logger *Logger, opt interface{}) { switch val := opt.(type) { case setNameOption: diff --git a/base/logs/logs.go b/base/logs/logs.go index 7cfb43f7..330fc028 100644 --- a/base/logs/logs.go +++ b/base/logs/logs.go @@ -14,6 +14,10 @@ package logs +import ( + "io" +) + // Logger . type Logger interface { Sub(name string) Logger @@ -32,4 +36,5 @@ type Logger interface { Fatalf(template string, args ...interface{}) SetLevel(lvl string) error + SetOutput(output io.Writer) }