From a3925e8aa0510ada4c5f580bc41341ba96dbcbcd Mon Sep 17 00:00:00 2001 From: Jason Wilder Date: Sun, 15 Feb 2015 13:51:41 -0700 Subject: [PATCH] CLI: Use console logger for dashbard:import command More consistent w/ other commands and separates stdout/stderr --- pkg/cmd/dashboard.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/pkg/cmd/dashboard.go b/pkg/cmd/dashboard.go index b37e06f4b8b..638c80cf38c 100644 --- a/pkg/cmd/dashboard.go +++ b/pkg/cmd/dashboard.go @@ -30,19 +30,16 @@ var ImportJson = cli.Command{ func runImport(c *cli.Context) { dir := c.String("dir") if len(dir) == 0 { - log.Error(3, "Missing command flag --dir") - return + log.ConsoleFatalf("Missing command flag --dir") } file, err := os.Stat(dir) if os.IsNotExist(err) { - log.Error(3, "Directory does not exist: %v", dir) - return + log.ConsoleFatalf("Directory does not exist: %v", dir) } if !file.IsDir() { - log.Error(3, "%v is not a directory", dir) - return + log.ConsoleFatalf("%v is not a directory", dir) } if !c.Args().Present() { @@ -57,8 +54,7 @@ func runImport(c *cli.Context) { accountQuery := m.GetAccountByNameQuery{Name: accountName} if err := bus.Dispatch(&accountQuery); err != nil { - log.Error(3, "Failed to find account", err) - return + log.ConsoleFatalf("Failed to find account", err) } accountId := accountQuery.Result.Id @@ -72,19 +68,19 @@ func runImport(c *cli.Context) { } if strings.HasSuffix(f.Name(), ".json") { if err := importDashboard(path, accountId); err != nil { - log.Error(3, "Failed to import dashboard file: %v, err: %v", path, err) + log.ConsoleFatalf("Failed to import dashboard file: %v, err: %v", path, err) } } return nil } if err := filepath.Walk(dir, visitor); err != nil { - log.Error(3, "failed to scan dir for json files: %v", err) + log.ConsoleFatalf("Failed to scan dir for json files: %v", err) } } func importDashboard(path string, accountId int64) error { - log.Info("Importing %v", path) + log.ConsoleInfof("Importing %v", path) reader, err := os.Open(path) if err != nil {