aboutsummaryrefslogtreecommitdiff
path: root/logger/logger.go
diff options
context:
space:
mode:
Diffstat (limited to 'logger/logger.go')
-rw-r--r--logger/logger.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/logger/logger.go b/logger/logger.go
index bb76657..9cd4b33 100644
--- a/logger/logger.go
+++ b/logger/logger.go
@@ -3,6 +3,7 @@ package logger
import (
"fmt"
+ "io"
"log"
"os"
"runtime/debug"
@@ -13,6 +14,7 @@ type severity int
type logger interface {
Output(calldepth int, s string) error
+ SetOutput(w io.Writer)
SetFlags(flag int)
}
@@ -103,6 +105,13 @@ func (l *Logger) output(s severity, depth int, txt string) {
l.loggers[s].Output(3+depth, txt+"\033[0m")
}
+// SetOutput changes the output of the logger.
+func (l *Logger) SetOutput(w io.Writer) {
+ for _, logger := range l.loggers {
+ logger.SetOutput(w)
+ }
+}
+
// SetFlags sets the output flags for the logger.
func (l *Logger) SetFlags(flag int) {
for _, logger := range l.loggers {
@@ -194,6 +203,11 @@ func (l *Logger) Fatalf(format string, v ...interface{}) {
os.Exit(1)
}
+// SetOutput changes the output of the default logger.
+func SetOutput(w io.Writer) {
+ defaultLogger.SetOutput(w)
+}
+
// SetFlags sets the output flags for the logger.
func SetFlags(flag int) {
defaultLogger.SetFlags(flag)