Skip to content

Commit

Permalink
chore: log debug messages when creating preview (#1475)
Browse files Browse the repository at this point in the history
chore: log debug messages when creating preview
  • Loading branch information
wmalik authored Feb 26, 2024
2 parents 7ac2bae + e1a81e8 commit f923b95
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
33 changes: 15 additions & 18 deletions cmd/terramate/cli/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,10 @@ func (c *cli) doPreviewBefore(run stackCloudRun) {
printer.Stderr.ErrorWithDetails("failed to update stack preview", err)
return
}
if !c.parsedArgs.Quiet {
printer.Stderr.Println(sprintf("terramate: stack:'%s' preview_status:%s",
run.Stack.Name,
preview.StackStatusRunning,
))
}
log.Debug().
Str("stack_name", run.Stack.Dir.String()).
Str("stack_preview_status", preview.StackStatusRunning.String()).
Msg("Setting stack preview status")
}

func (c *cli) doPreviewAfter(run stackCloudRun, res runResult) {
Expand Down Expand Up @@ -346,15 +344,14 @@ func (c *cli) doPreviewAfter(run stackCloudRun, res runResult) {
return
}

if !c.parsedArgs.Quiet {
msg := sprintf("terramate: stack:'%s' preview_status:%s",
run.Stack.Dir.String(),
previewStatus.String(),
)
if previewChangeset != nil {
msg = sprintf("%s (with changeset)", msg)
}
printer.Stderr.Println(msg)
logger := log.With().
Str("stack_name", run.Stack.Dir.String()).
Str("stack_preview_status", previewStatus.String()).
Logger()

logger.Debug().Msg("Setting stack preview status")
if previewChangeset != nil {
logger.Debug().Msg("Sending changelog")
}
}

Expand Down Expand Up @@ -513,9 +510,9 @@ func (c *cli) detectCloudMetadata() {

pull, err := getGithubPRByNumberOrCommit(githubClient, ghToken, r.Owner, r.Name, prNumber, headCommit)
if err != nil {
printer.Stderr.WarnWithDetails(
sprintf("failed to retrieve pull request (number: %d, commit: %s)", prNumber, headCommit),
err)
logger.Debug().Err(err).
Int("number", prNumber).
Msg("failed to retrieve pull_request")
return
}

Expand Down
5 changes: 4 additions & 1 deletion cmd/terramate/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@ func (c *cli) runAll(
printScriptCommand(c.stderr, run.Stack, task)
}

if !opts.Quiet && !opts.ScriptRun {
printer.Stderr.Println(printPrefix + " Entering stack in " + run.Stack.String())
}

c.cloudSyncBefore(cloudRun)

environ := newEnvironFrom(stackEnvs[run.Stack.Dir])
Expand All @@ -343,7 +347,6 @@ func (c *cli) runAll(
}

if !opts.Quiet && !opts.ScriptRun {
printer.Stderr.Println(printPrefix + " Entering stack in " + run.Stack.String())
printer.Stderr.Println(printPrefix + " Executing command " + strconv.Quote(cmdStr))
}

Expand Down

0 comments on commit f923b95

Please sign in to comment.