Skip to content

Commit

Permalink
fix: cli warn and error should go to stdout like the lower levels (#1522
Browse files Browse the repository at this point in the history
)

* fix: cli warn and error should go to stdout like the lower levels

* fatal logs to stderr

* f
  • Loading branch information
emosbaugh authored Nov 19, 2024
1 parent fef6b67 commit 3d9d9a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions e2e/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,7 @@ func TestMultiNodeHAInstallation(t *testing.T) {
if err != nil {
t.Fatalf("fail to remove controller node 2: %v: %s: %s", err, stdout, stderr)
}
if !strings.Contains(stderr, "High-availability clusters must maintain at least three controller nodes") {
if !strings.Contains(stdout, "High-availability clusters must maintain at least three controller nodes") {
t.Errorf("reset output does not contain the ha warning")
t.Logf("stdout: %s\nstderr: %s", stdout, stderr)
}
Expand Down Expand Up @@ -2035,7 +2035,7 @@ func TestMultiNodeAirgapHAInstallation(t *testing.T) {
t.Logf("stdout: %s\nstderr: %s", stdout, stderr)
t.Fatalf("fail to remove controller node %s:", err)
}
if !strings.Contains(stderr, "High-availability clusters must maintain at least three controller nodes") {
if !strings.Contains(stdout, "High-availability clusters must maintain at least three controller nodes") {
t.Errorf("reset output does not contain the ha warning")
t.Logf("stdout: %s\nstderr: %s", stdout, stderr)
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import (
"time"

"github.com/fatih/color"
"github.com/sirupsen/logrus"

"github.com/replicatedhq/embedded-cluster/pkg/defaults"
"github.com/sirupsen/logrus"
)

// MaxLogFiles is the maximum number of log files we keep.
const MaxLogFiles = 100

// StdoutLogger is a Logrus hook for routing Info, Error, and Fatal logs to the screen.
// StdoutLogger is a Logrus hook for routing Info, Warn and Error logs to stdout and Fatal logs to
// stderr.
type StdoutLogger struct{}

// Levels defines on which log levels this hook would trigger.
Expand All @@ -36,7 +36,7 @@ func (hook *StdoutLogger) Levels() []logrus.Level {
func (hook *StdoutLogger) Fire(entry *logrus.Entry) error {
message := fmt.Sprintf("%s\n", entry.Message)
output := os.Stdout
if entry.Level != logrus.InfoLevel {
if entry.Level == logrus.FatalLevel {
output = os.Stderr
}
var writer *color.Color
Expand Down

0 comments on commit 3d9d9a8

Please sign in to comment.