From e7c1c3171697807acf6d3878de6f779aec1f5fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Mon, 20 Nov 2023 16:23:54 +0100 Subject: [PATCH] Copy output to Stdout for more convenient local development --- windows-agent/cmd/ubuntu-pro-agent/main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/windows-agent/cmd/ubuntu-pro-agent/main.go b/windows-agent/cmd/ubuntu-pro-agent/main.go index 31f7a8288..47d86048b 100644 --- a/windows-agent/cmd/ubuntu-pro-agent/main.go +++ b/windows-agent/cmd/ubuntu-pro-agent/main.go @@ -5,6 +5,7 @@ import ( "context" "errors" "fmt" + "io" "os" "os/signal" "path/filepath" @@ -77,7 +78,10 @@ func setLoggerOutput() (func(), error) { } fmt.Fprintf(f, "\n======== Startup %s ========\n", time.Now().Format(time.RFC3339)) - log.SetOutput(f) + + // Write both to file and to Stdout. The latter is useful for local development. + w := io.MultiWriter(f, os.Stdout) + log.SetOutput(w) return func() { _ = f.Close() }, nil }