17609: Add diagnostics command.
[arvados.git] / lib / costanalyzer / cmd.go
index 9b0685225b788ba2bf35b469eded10575367e2c3..633e95e29f6f71b2b1cb6e48d1e28ed6beacd82a 100644 (file)
@@ -7,33 +7,26 @@ package costanalyzer
 import (
        "io"
 
+       "git.arvados.org/arvados.git/lib/cmd"
        "git.arvados.org/arvados.git/lib/config"
        "git.arvados.org/arvados.git/sdk/go/ctxlog"
-       "github.com/sirupsen/logrus"
 )
 
 var Command command
 
 type command struct{}
 
-type NoPrefixFormatter struct{}
-
-func (f *NoPrefixFormatter) Format(entry *logrus.Entry) ([]byte, error) {
-       return []byte(entry.Message), nil
-}
-
 // RunCommand implements the subcommand "costanalyzer <collection> <collection> ..."
 func (command) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int {
        var err error
        logger := ctxlog.New(stderr, "text", "info")
+       logger.SetFormatter(cmd.NoPrefixFormatter{})
        defer func() {
                if err != nil {
                        logger.Error("\n" + err.Error() + "\n")
                }
        }()
 
-       logger.SetFormatter(new(NoPrefixFormatter))
-
        loader := config.NewLoader(stdin, logger)
        loader.SkipLegacy = true