Skip to content

Commit

Permalink
Update appscode/go log wrapper (#287)
Browse files Browse the repository at this point in the history
* Revendor dependencies
* Pass through logger flags
  • Loading branch information
tamalsaha authored Jan 17, 2018
1 parent 470cc31 commit cf3ea7c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log"
"strings"

"github.com/appscode/go/log/golog"
v "github.com/appscode/go/version"
"github.com/appscode/kutil/tools/analytics"
"github.com/appscode/stash/client/scheme"
Expand All @@ -20,9 +21,6 @@ const (
)

func NewRootCmd() *cobra.Command {
var (
enableAnalytics = true
)
var rootCmd = &cobra.Command{
Use: "stash",
Short: `Stash by AppsCode - Backup your Kubernetes Volumes`,
Expand All @@ -32,7 +30,7 @@ func NewRootCmd() *cobra.Command {
c.Flags().VisitAll(func(flag *pflag.Flag) {
log.Printf("FLAG: --%s=%q", flag.Name, flag.Value)
})
if enableAnalytics && gaTrackingCode != "" {
if util.EnableAnalytics && gaTrackingCode != "" {
if client, err := ga.NewClient(gaTrackingCode); err == nil {
util.AnalyticsClientID = analytics.ClientID()
client.ClientID(util.AnalyticsClientID)
Expand All @@ -41,12 +39,13 @@ func NewRootCmd() *cobra.Command {
}
}
scheme.AddToScheme(clientsetscheme.Scheme)
util.LoggerOptions = golog.ParseFlags(c.Flags())
},
}
rootCmd.PersistentFlags().AddGoFlagSet(flag.CommandLine)
// ref: https://github.com/kubernetes/kubernetes/issues/17162#issuecomment-225596212
flag.CommandLine.Parse([]string{})
rootCmd.PersistentFlags().BoolVar(&enableAnalytics, "analytics", enableAnalytics, "Send analytical events to Google Analytics")
rootCmd.PersistentFlags().BoolVar(&util.EnableAnalytics, "analytics", util.EnableAnalytics, "Send analytical events to Google Analytics")

rootCmd.AddCommand(v.NewCmdVersion())
rootCmd.AddCommand(NewCmdRun())
Expand Down

0 comments on commit cf3ea7c

Please sign in to comment.