From 6d72050e813184ce27fa8d88082ba87e26e2c29e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98istein=20Sletten=20L=C3=B8vik?= Date: Fri, 16 Sep 2022 05:06:44 +0000 Subject: [PATCH] logCmdOutput to logger instead of stdout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Øistein Sletten Løvik --- pkg/loadtester/bash.go | 2 +- pkg/loadtester/helmv3.go | 2 +- pkg/loadtester/task_shell.go | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/loadtester/bash.go b/pkg/loadtester/bash.go index 22942b70b..653ec25a4 100644 --- a/pkg/loadtester/bash.go +++ b/pkg/loadtester/bash.go @@ -43,7 +43,7 @@ func (task *BashTask) Run(ctx context.Context) (*TaskRunResult, error) { return &TaskRunResult{false, out}, fmt.Errorf("command %s failed: %s: %w", task.command, out, err) } else { if task.logCmdOutput { - fmt.Printf("%s\n", out) + task.logger.With("canary", task.canary).Info(string(out)) } task.logger.With("canary", task.canary).Infof("command finished %s", task.command) } diff --git a/pkg/loadtester/helmv3.go b/pkg/loadtester/helmv3.go index c801952b8..a79373036 100644 --- a/pkg/loadtester/helmv3.go +++ b/pkg/loadtester/helmv3.go @@ -47,7 +47,7 @@ func (task *HelmTaskv3) Run(ctx context.Context) (*TaskRunResult, error) { return &TaskRunResult{false, out}, fmt.Errorf("command %s failed: %s: %w", task.command, out, err) } else { if task.logCmdOutput { - fmt.Printf("%s\n", out) + task.logger.With("canary", task.canary).Info(string(out)) } task.logger.With("canary", task.canary).Infof("command finished %v", helmCmd) } diff --git a/pkg/loadtester/task_shell.go b/pkg/loadtester/task_shell.go index 3db6f92b4..de271f1fc 100644 --- a/pkg/loadtester/task_shell.go +++ b/pkg/loadtester/task_shell.go @@ -19,7 +19,6 @@ package loadtester import ( "context" "errors" - "fmt" "os/exec" "strconv" @@ -57,7 +56,7 @@ func (task *CmdTask) Run(ctx context.Context) *TaskRunResult { task.logger.With("canary", task.canary).Errorf("command failed %s %v %s", task.command, err, out) } else { if task.logCmdOutput { - fmt.Printf("%s\n", out) + task.logger.With("canary", task.canary).Info(string(out)) } task.logger.With("canary", task.canary).Infof("command finished %s", task.command) }