Skip to content

Commit

Permalink
Revert "DEVPROD-13406: silence patch info logs for JSON output (#8599)"
Browse files Browse the repository at this point in the history
This reverts commit 705d8f6.
  • Loading branch information
Kimchelly committed Jan 9, 2025
1 parent 5e0e6e2 commit c11a32d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 20 deletions.
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var (

// ClientVersion is the commandline version string used to control updating
// the CLI. The format is the calendar date (YYYY-MM-DD).
ClientVersion = "2025-01-09b"
ClientVersion = "2025-01-09"

// Agent version to control agent rollover. The format is the calendar date
// (YYYY-MM-DD).
Expand Down
11 changes: 1 addition & 10 deletions operations/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/evergreen-ci/evergreen/util"
"github.com/evergreen-ci/utility"
"github.com/mongodb/grip"
"github.com/mongodb/grip/level"
"github.com/pkg/errors"
"github.com/urfave/cli"
)
Expand Down Expand Up @@ -121,14 +120,6 @@ func Patch() cli.Command {
Action: func(c *cli.Context) error {
confPath := c.Parent().String(confFlagName)
outputJSON := c.Bool(jsonFlagName)
if outputJSON {
// If outputting the patch data as JSON, suppress any non-error
// logs since the logs won't be in JSON format. Errors should
// still appear so users can diagnose issues.
l := grip.GetSender().Level()
l.Threshold = level.Error
grip.Error(errors.Wrap(grip.SetLevel(l), "increasing log level to suppress non-errors for JSON output"))
}
args := c.Args()
params := &patchParams{
Project: c.String(projectFlagName),
Expand Down Expand Up @@ -266,7 +257,7 @@ func Patch() cli.Command {
continue
}
if err = addModuleToPatch(params, args, conf, newPatch, &module, modulePath); err != nil {
grip.Errorf("Error adding module '%s' to patch: %s", module.Name, err)
grip.ErrorWhen(!outputJSON, fmt.Sprintf("Error adding module '%s' to patch: %s", module.Name, err))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion operations/patch_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func addModuleToPatch(params *patchParams, args cli.Args, conf *ClientSettings,
if !params.SkipConfirm {
grip.Infof("Using branch '%s' for module '%s'.", module.Branch, module.Name)
if diffData.patchSummary != "" {
grip.Info(diffData.patchSummary)
fmt.Println(diffData.patchSummary)
}
if len(diffData.fullPatch) > 0 {
if !confirm("This is a summary of the module patch to be submitted. Include this module's changes?", true) {
Expand Down
12 changes: 4 additions & 8 deletions operations/patch_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,8 @@ func (p *patchParams) displayPatch(ac *legacyClient, params outputPatchParams) e
return err
}

grip.Info("Patch successfully created.")
// This is intentionally using fmt.Println instead of grip because if the
// output is JSON, informational grip logs are suppressed. Using fmt.Println
// ensures the patch output is displayed regardless of logging
// configuration.
fmt.Println(patchDisp)
grip.InfoWhen(!params.outputJSON, "Patch successfully created.")
grip.Info(patchDisp)

if len(params.patches) == 1 && p.Browse {
browserCmd, err := findBrowserCommand()
Expand Down Expand Up @@ -240,7 +236,7 @@ func findBrowserCommand() ([]string, error) {
// Performs validation for patch or patch-file
func (p *patchParams) validatePatchCommand(ctx context.Context, conf *ClientSettings, ac *legacyClient, comm client.Communicator) (*model.ProjectRef, error) {
if err := p.loadProject(conf); err != nil {
grip.Errorf("failed to resolve project: %s\n", err)
grip.Warningf("warning - failed to set default project: %v\n", err)
}

// If reusing a previous definition, ignore defaults.
Expand All @@ -249,7 +245,7 @@ func (p *patchParams) validatePatchCommand(ctx context.Context, conf *ClientSett
}

if err := p.loadParameters(conf); err != nil {
grip.Warningf("warning - failed to set default parameters: %s\n", err)
grip.Warningf("warning - failed to set default parameters: %v\n", err)
}

if p.Uncommitted || conf.UncommittedChanges {
Expand Down

0 comments on commit c11a32d

Please sign in to comment.