From d7df2eebe31299ebf6bdae2c3152cd2291ddb701 Mon Sep 17 00:00:00 2001 From: Stanley Shyiko Date: Fri, 22 Jul 2016 13:23:36 -0700 Subject: [PATCH] Switched to SimpleFormatter (so that output on Windows would be readable) --- command/install.go | 1 + jabba.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/command/install.go b/command/install.go index 1a4c1c8..de46d16 100644 --- a/command/install.go +++ b/command/install.go @@ -312,6 +312,7 @@ func installFromBin(source string, target string) (err error) { } func installFromExe(source string, target string) error { + log.Info("Unpacking " + source + " to " + target) // using ShellExecute instead of exec.Command so user could decide whether to trust the installer when UAC is active return w32.ShellExecuteAndWait(w32.HWND(0), "open", source, "/s INSTALLDIR=\"" + target + "\" STATIC=1 AUTO_UPDATE=0 WEB_JAVA=0 WEB_ANALYTICS=0 REBOOT=0", "", 3) diff --git a/jabba.go b/jabba.go index c5f40d4..d175737 100644 --- a/jabba.go +++ b/jabba.go @@ -11,16 +11,30 @@ import ( "sort" "io/ioutil" "strings" + "bytes" ) var version string var rootCmd *cobra.Command func init() { + log.SetFormatter(&SimpleFormatter{}) // todo: make it configurable through the command line log.SetLevel(log.InfoLevel) } +type SimpleFormatter struct {} + +func (f *SimpleFormatter) Format(entry *log.Entry) ([]byte, error) { + b := &bytes.Buffer{} + fmt.Fprintf(b, "%s ", entry.Message) + for k, v := range entry.Data { + fmt.Fprintf(b, "%s=%+v ", k, v) + } + b.WriteByte('\n') + return b.Bytes(), nil +} + func main() { rootCmd = &cobra.Command{ Use: "jabba",