Skip to content

Commit

Permalink
feat: log out the formatter command being applied at debug level
Browse files Browse the repository at this point in the history
Closes #292

Signed-off-by: Brian McGee <[email protected]>
  • Loading branch information
brianmcgee committed May 17, 2024
1 parent 2b94480 commit 1f76024
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions format/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ func (f *Formatter) Apply(ctx context.Context, files []*walk.File, filter bool)
cmd := exec.CommandContext(ctx, f.executable, args...)
cmd.Dir = f.workingDir

// log out the command being executed, truncating it as required
if f.log.GetLevel() == log.DebugLevel {
cmdStr := cmd.String()
if len(cmdStr) >= 1024 {
cmdStr = cmdStr[:1024] + "..."
}
f.log.Debugf("executing: %s", cmd.String())
}

if out, err := cmd.CombinedOutput(); err != nil {
if len(out) > 0 {
_, _ = fmt.Fprintf(os.Stderr, "%s error:\n%s\n", f.name, out)
Expand Down

0 comments on commit 1f76024

Please sign in to comment.