Skip to content

Commit

Permalink
improved logging
Browse files Browse the repository at this point in the history
  • Loading branch information
kbudde committed Dec 21, 2023
1 parent c216f37 commit f33dbc5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions internal/myks/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ func (p PluginCmd) Exec(a *Application) error {
env["MYKS_ARGOCD_APP_NAME"] = a.getArgoCDDestinationDir()
env["MYKS_ARGOCD_APP_PROJECT"] = "rendered/argocd/" + a.e.Id + "/" + a.Name // TODO: provide func and use it everywhere,
}
prefix := "[" + p.name + "] " + a.e.Id + "/" + a.Name + ": "
log.Info().Msg(prefix + "Executing plugin")

log.Trace().Msg(a.Msg("Plugin "+p.Name(), "execution started"))

cmd := exec.Command(p.cmd, []string{}...)

Expand All @@ -124,9 +124,13 @@ func (p PluginCmd) Exec(a *Application) error {

err := cmd.Run()
if err != nil {
log.Error().Err(err).Msg(prefix + "Plugin execution failed")
log.Info().Msg(prefix + "Stdout: " + stdoutBs.String())
log.Info().Msg(prefix + "Stderr: " + stderrBs.String())
log.Error().Err(err).
Str("stderr", stderrBs.String()).
Str("stdout", stdoutBs.String()).
Msg(a.Msg("Plugin "+p.Name(), "Plugin execution failed"))
} else {
log.Debug().Str("stdout", stdoutBs.String()).
Msg(a.Msg("Plugin "+p.Name(), "Plugin execution succeeded"))
}
return err
}

0 comments on commit f33dbc5

Please sign in to comment.