From 47af93d47535be0b6740edff3d6053ea9ba55bdb Mon Sep 17 00:00:00 2001 From: Nathan LeClaire Date: Wed, 11 Mar 2015 14:44:33 -0700 Subject: [PATCH] Add flexible JSON dump debugging method Signed-off-by: Nathan LeClaire --- utils/utils.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/utils/utils.go b/utils/utils.go index a6f4e3626b..d63e05052e 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -1,12 +1,15 @@ package utils import ( + "encoding/json" "fmt" "io" "os" "path/filepath" "runtime" "time" + + log "github.com/Sirupsen/logrus" ) func GetHomeDir() string { @@ -95,3 +98,13 @@ func WaitForSpecific(f func() bool, maxAttempts int, waitInterval time.Duration) func WaitFor(f func() bool) error { return WaitForSpecific(f, 60, 3*time.Second) } + +func DumpVal(vals ...interface{}) { + for _, val := range vals { + prettyJSON, err := json.MarshalIndent(val, "", " ") + if err != nil { + log.Fatal(err) + } + log.Debug(string(prettyJSON)) + } +}