Skip to content

Commit

Permalink
logCmdOutput to logger instead of stdout
Browse files Browse the repository at this point in the history
Signed-off-by: Øistein Sletten Løvik <[email protected]>
  • Loading branch information
oistein committed Sep 26, 2022
1 parent 89b0487 commit 6d72050
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/loadtester/bash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/loadtester/helmv3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/loadtester/task_shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package loadtester
import (
"context"
"errors"
"fmt"
"os/exec"
"strconv"

Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 6d72050

Please sign in to comment.