X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/523d1c2a9963edc25becf7958e024992ed8a6e66..0ea9427622c1f4179c7324cb57b0d6d2aa4970b6:/lib/costanalyzer/cmd.go diff --git a/lib/costanalyzer/cmd.go b/lib/costanalyzer/cmd.go index 525ec619b5..f2a7af4933 100644 --- a/lib/costanalyzer/cmd.go +++ b/lib/costanalyzer/cmd.go @@ -8,8 +8,8 @@ import ( "io" "time" + "git.arvados.org/arvados.git/lib/cmd" "git.arvados.org/arvados.git/sdk/go/ctxlog" - "github.com/sirupsen/logrus" ) var Command = command{} @@ -22,25 +22,15 @@ type command struct { end time.Time } -type NoPrefixFormatter struct{} - -func (f *NoPrefixFormatter) Format(entry *logrus.Entry) ([]byte, error) { - return []byte(entry.Message), nil -} - // RunCommand implements the subcommand "costanalyzer ..." func (c command) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int { var err error logger := ctxlog.New(stderr, "text", "info") - defer func() { - if err != nil { - logger.Error("\n" + err.Error() + "\n") - } - }() - - logger.SetFormatter(new(NoPrefixFormatter)) + logger.SetFormatter(cmd.NoPrefixFormatter{}) exitcode, err := c.costAnalyzer(prog, args, logger, stdout, stderr) - + if err != nil { + logger.Error("\n" + err.Error()) + } return exitcode }