Skip to content

Commit

Permalink
use log.* instead of fmt.Print*
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanking committed Jul 16, 2018
1 parent 2163de1 commit a29a393
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package cmd

import (
"fmt"
"os"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

Expand All @@ -17,7 +17,7 @@ var rootCmd = &cobra.Command{

func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
log.Fatal(err)
os.Exit(1)
}
}
11 changes: 5 additions & 6 deletions cmd/util.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cmd

import (
"fmt"
"os"

"github.com/chanzuckerberg/fogg/config"
Expand All @@ -15,7 +14,7 @@ func openGitOrExit(pwd string) *git.Repository {
g, err := git.PlainOpen(pwd)
if err != nil {
// assuming this means no repository
fmt.Println("fogg must be run from the root of a git repo")
log.Fatal("fogg must be run from the root of a git repo")
os.Exit(1)
}
return g
Expand All @@ -27,8 +26,8 @@ func readAndValidateConfig(fs afero.Fs, configFile string, verbose bool) (*confi
return nil, err
}
if verbose {
fmt.Println("CONFIG")
fmt.Printf("%#v\n=====", config)
log.Debug("CONFIG")
log.Debug("%#v\n=====", config)
}

err = config.Validate()
Expand All @@ -37,11 +36,11 @@ func readAndValidateConfig(fs afero.Fs, configFile string, verbose bool) (*confi

func exitOnConfigErrors(err error) {
if err != nil {
fmt.Println("Config Error(s):")
log.Error("Config Error(s):")
errs, ok := err.(validator.ValidationErrors)
if ok {
for _, err := range errs {
fmt.Printf("\t%s is a %s %s\n", err.Namespace(), err.Tag(), err.Kind())
log.Error("\t%s is a %s %s\n", err.Namespace(), err.Tag(), err.Kind())
}
} else {
log.Panic(err)
Expand Down
5 changes: 2 additions & 3 deletions util/debugging.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package util

import "fmt"
import log "github.com/sirupsen/logrus"

func Dump(foo interface{}) {
fmt.Printf("%#v\n", foo)

log.Printf("%#v\n", foo)
}
3 changes: 1 addition & 2 deletions util/template.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package util

import (
"fmt"
"io"
"io/ioutil"
"reflect"
Expand All @@ -17,7 +16,7 @@ func dict(in interface{}) map[string]interface{} {
r := make(map[string]interface{})
for _, key := range v.MapKeys() {
strct := v.MapIndex(key)
fmt.Println(key.Interface(), strct.Interface())
log.Debug(key.Interface(), strct.Interface())
r[key.String()] = strct.Interface()
}
return r
Expand Down

0 comments on commit a29a393

Please sign in to comment.