From ee309da1a699fc5e94a97e9b25ca5663d43c2c0b Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Tue, 16 Jun 2020 14:41:55 -0400 Subject: [PATCH] output from enrolling in ziti-tunnel should be nicer too --- ziti-tunnel/cmd/ziti-tunnel/subcmd/enroll.go | 12 +++++++++++- ziti-tunnel/cmd/ziti-tunnel/subcmd/root.go | 3 +-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ziti-tunnel/cmd/ziti-tunnel/subcmd/enroll.go b/ziti-tunnel/cmd/ziti-tunnel/subcmd/enroll.go index 6d2fb0802..700834abb 100644 --- a/ziti-tunnel/cmd/ziti-tunnel/subcmd/enroll.go +++ b/ziti-tunnel/cmd/ziti-tunnel/subcmd/enroll.go @@ -66,6 +66,8 @@ func init() { } var enrollSubCmd = &cobra.Command{ + SilenceErrors: true, + SilenceUsage: true, Use: "enroll", Short: "enroll an identity", PersistentPreRun: func(cmd *cobra.Command, args []string) { @@ -74,6 +76,14 @@ var enrollSubCmd = &cobra.Command{ } }, RunE: func(cmd *cobra.Command, args []string) error { + //set the formatter for enrolling via ziti-tunnel + logrus.SetFormatter(&logrus.TextFormatter{ + ForceColors: true, + DisableTimestamp: true, + TimestampFormat: "", + PadLevelText: true, + }) + logrus.SetReportCaller(false) // for enrolling don't bother with this return processEnrollment() }, } @@ -135,7 +145,7 @@ func processEnrollment() error { encErr := enc.Encode(&conf) if encErr == nil { - fmt.Printf("enrolled successfully. identity file written to: %s", outpath) + logrus.Errorf("enrolled successfully. identity file written to: %s", outpath) return nil } else { return fmt.Errorf("enrollment successful but the identity file was not able to be written to: %s [%s]", outpath, encErr) diff --git a/ziti-tunnel/cmd/ziti-tunnel/subcmd/root.go b/ziti-tunnel/cmd/ziti-tunnel/subcmd/root.go index 25a1d811c..fcd8477a1 100644 --- a/ziti-tunnel/cmd/ziti-tunnel/subcmd/root.go +++ b/ziti-tunnel/cmd/ziti-tunnel/subcmd/root.go @@ -17,7 +17,6 @@ package subcmd import ( - "fmt" "github.com/michaelquigley/pfxlog" "github.com/openziti/edge/tunnel/dns" "github.com/openziti/edge/tunnel/entities" @@ -56,7 +55,7 @@ var logFormatter string func Execute() { if err := root.Execute(); err != nil { - fmt.Printf("error: %s", err) + pfxlog.Logger().Errorf("error: %s", err) } }