Skip to content

Commit

Permalink
fixes issue-2341 wrt logging and stdout/stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
christophercampbell committed Jan 23, 2025
1 parent 84e2fe2 commit 1932f38
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
13 changes: 7 additions & 6 deletions cli/cli/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ package commands
import (
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"strings"
"time"

"github.com/Masterminds/semver/v3"
"github.com/kurtosis-tech/kurtosis/cli/cli/command_str_consts"
"github.com/kurtosis-tech/kurtosis/cli/cli/commands/analytics"
Expand Down Expand Up @@ -47,11 +53,6 @@ import (
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"io"
"net/http"
"os"
"strings"
"time"
)

const (
Expand Down Expand Up @@ -186,7 +187,7 @@ func setupCLILogs(cmd *cobra.Command) error {
if err != nil {
return stacktrace.Propagate(err, "Could not parse log level string '%v'", logLevelStr)
}
logrus.SetOutput(cmd.OutOrStdout())
logrus.SetOutput(cmd.OutOrStderr())
logrus.SetLevel(logLevel)
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion cli/cli/commands/service/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ func run(
if successResult.GetExitCode() != 0 {
return stacktrace.NewError("The command was successfully executed but returned a non-zero exit code: '%d'. Output was:\n%v", successResult.GetExitCode(), successResult.GetOutput())
}
out.PrintOutLn(fmt.Sprintf("The command was successfully executed and returned '%d'. Output was:\n%v", successResult.GetExitCode(), successResult.GetOutput()))
out.PrintErrLn(fmt.Sprintf("The command was successfully executed and returned '%d'.", successResult.GetExitCode()))
out.PrintOutLn(successResult.GetOutput())
return nil
}

0 comments on commit 1932f38

Please sign in to comment.