Skip to content

Commit d628a49

Browse files
authored
fix(core): logger level error as default when output is not human (#2790)
1 parent cc21342 commit d628a49

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

docs/developer.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ go test ./internal/namespaces/init -debug
5454

5555
When you are developing tests, you can also use the `Logger` field that is available in the different contexts to write your own logs.
5656

57+
### Checking the version
58+
59+
When you are running CLI commands the version check is made in every action. You can avoid these output setting `SCW_DISABLE_CHECK_VERSION` to false.
60+
5761
#### Targeting specific tests
5862

5963
The test suite is design to run quickly, but when you are recording interactions you probably don't want to record interactions for all the tests in the test suite.

internal/core/bootstrap.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ type BootstrapConfig struct {
6666
BetaMode bool
6767
}
6868

69+
const (
70+
defaultOutput = "human"
71+
)
72+
6973
// Bootstrap is the main entry point. It is directly called from main.
7074
// BootstrapConfig.Args is usually os.Args
7175
// BootstrapConfig.Commands is a list of command available in CLI.
@@ -79,7 +83,7 @@ func Bootstrap(config *BootstrapConfig) (exitCode int, result interface{}, err e
7983
flags := pflag.NewFlagSet(config.Args[0], pflag.ContinueOnError)
8084
flags.StringVarP(&profileFlag, "profile", "p", "", "The config profile to use")
8185
flags.StringVarP(&configPathFlag, "config", "c", "", "The path to the config file")
82-
flags.StringVarP(&outputFlag, "output", "o", "human", "Output format: json or human")
86+
flags.StringVarP(&outputFlag, "output", "o", defaultOutput, "Output format: json or human")
8387
flags.BoolVarP(&debug, "debug", "D", os.Getenv("SCW_DEBUG") == "true", "Enable debug mode")
8488
// Ignore unknown flag
8589
flags.ParseErrorsWhitelist.UnknownFlags = true
@@ -96,11 +100,15 @@ func Bootstrap(config *BootstrapConfig) (exitCode int, result interface{}, err e
96100

97101
// If debug flag is set enable debug mode in SDK logger
98102
logLevel := logger.LogLevelWarning
103+
if outputFlag != defaultOutput {
104+
logLevel = logger.LogLevelError
105+
}
106+
99107
if debug {
100108
logLevel = logger.LogLevelDebug // enable debug mode
101109
}
102110

103-
// We force log to os.Stderr because we dont have a scoped logger feature and it create
111+
// We force log to os.Stderr because we don't have a scoped logger feature, and it creates
104112
// concurrency situation with golden files
105113
log := config.Logger
106114
if log == nil {

0 commit comments

Comments
 (0)