From 07d200b353e1f8d0c33fb91ad87a9d984230cf66 Mon Sep 17 00:00:00 2001 From: Johannes Kresner Date: Fri, 26 Jan 2024 15:57:47 +0100 Subject: [PATCH] fix: add multi writer add multi writer to support both file output and std out --- internal/flags/flags.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/flags/flags.go b/internal/flags/flags.go index a2183c11b..e4db2353e 100644 --- a/internal/flags/flags.go +++ b/internal/flags/flags.go @@ -4,6 +4,7 @@ import ( "bufio" "errors" "fmt" + "io" "os" "regexp" "strings" @@ -691,7 +692,8 @@ func SetupLogging(f *pflag.FlagSet) error { return fmt.Errorf("failed to open log file: %e", err) } } - log.SetOutput(logFile) + multiWriter := io.MultiWriter(os.Stdout, os.Stderr, logFile) + log.SetOutput(multiWriter) } return nil