Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove leftover log level handlings #824

Merged
merged 6 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var (
// App flags
flDebugMode = cli.BoolFlag{
Name: DebugModeKey,
Usage: "If true it enabled DEBUG mode. If no separate Log Level is specified this will also set the loglevel to debug.",
Usage: "If true it enables DEBUG mode.",
EnvVar: configs.DebugModeEnvKey,
}
flTool = cli.BoolFlag{
Expand Down
2 changes: 0 additions & 2 deletions configs/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ const (
PullRequestIDEnvKey = "PULL_REQUEST_ID"
// DebugModeEnvKey ...
DebugModeEnvKey = "DEBUG"
// LogLevelEnvKey ...
LogLevelEnvKey = "LOGLEVEL"
// IsSecretFilteringKey ...
IsSecretFilteringKey = "BITRISE_SECRET_FILTERING"
// IsSecretEnvsFilteringKey ...
Expand Down
22 changes: 7 additions & 15 deletions tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ func StepmanStepInfo(collection, stepID, stepVersion string) (stepmanModels.Step

// StepmanRawStepList ...
func StepmanRawStepList(collection string) (string, error) {
args := []string{"--loglevel", logLevel(), "step-list", "--collection", collection, "--format", "raw"}
args := []string{"step-list", "--collection", collection, "--format", "raw"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user can set the debug mode in two ways:

  • env var
  • command line parameter

The stepman process inherits the envs from the parent process so if the user used the debug env key then stepman can also print the debug logs.

But if the user used the command line parameters then the cli will print debug logs but stepman will not because we are not passing the loglevel anymore.

I do not know yet how useful the stepman debug logs are so I am also happy to remove this. But if we want consistency then I would add the --loglevel debug parameter to stepman in the case if we are running in a debug mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated my PR to restore the original behaviour around debug mode.
Now envan and stepman inherits Bitrise CLIs debug mode, this involved 2 main changes:

  • improved how we parse debug mode flag (loggerParameters) + tests
  • setting LOGLEVEL=debug env var

Specifying --loglevel=debug flag for the envman and stepman commands is not needed because the LOGLEVEL env var controls the log level flag for both stepman and envman.

On the other side, specifying --loglevel=debug in itself is not enough, because this way we restore the behavior for wrapped commands of envman and stepman, but not for the envman and stepman plugin commands:

  • Plugin command: bitrise -debug stepman share audit
  • Wrapped command: bitrise -debug share audit

return command.RunCommandAndReturnCombinedStdoutAndStderr("stepman", args...)
}

// StepmanJSONStepList ...
func StepmanJSONStepList(collection string) (string, error) {
args := []string{"--loglevel", logLevel(), "step-list", "--collection", collection, "--format", "json"}
args := []string{"step-list", "--collection", collection, "--format", "json"}

var outBuffer bytes.Buffer
var errBuffer bytes.Buffer
Expand All @@ -183,31 +183,31 @@ func StepmanJSONStepList(collection string) (string, error) {

// StepmanShare ...
func StepmanShare() error {
args := []string{"--loglevel", logLevel(), "share", "--toolmode"}
args := []string{"share", "--toolmode"}
return command.RunCommand("stepman", args...)
}

// StepmanShareAudit ...
func StepmanShareAudit() error {
args := []string{"--loglevel", logLevel(), "share", "audit", "--toolmode"}
args := []string{"share", "audit", "--toolmode"}
return command.RunCommand("stepman", args...)
}

// StepmanShareCreate ...
func StepmanShareCreate(tag, git, stepID string) error {
args := []string{"--loglevel", logLevel(), "share", "create", "--tag", tag, "--git", git, "--stepid", stepID, "--toolmode"}
args := []string{"share", "create", "--tag", tag, "--git", git, "--stepid", stepID, "--toolmode"}
return command.RunCommand("stepman", args...)
}

// StepmanShareFinish ...
func StepmanShareFinish() error {
args := []string{"--loglevel", logLevel(), "share", "finish", "--toolmode"}
args := []string{"share", "finish", "--toolmode"}
return command.RunCommand("stepman", args...)
}

// StepmanShareStart ...
func StepmanShareStart(collection string) error {
args := []string{"--loglevel", logLevel(), "share", "start", "--collection", collection, "--toolmode"}
args := []string{"share", "start", "--collection", collection, "--toolmode"}
return command.RunCommand("stepman", args...)
}

Expand Down Expand Up @@ -389,17 +389,9 @@ func IsBuiltInFlagTypeKey(env string) bool {
configs.CIModeEnvKey,
configs.PRModeEnvKey,
configs.DebugModeEnvKey,
configs.LogLevelEnvKey,
configs.PullRequestIDEnvKey:
return true
default:
return false
}
}

func logLevel() string {
if configs.IsDebugMode {
return "debug"
}
return "info"
}