diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-05-10 00:12:23 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-05-10 00:12:23 -0700 |
commit | 6235211860b5b3794dfe9e64bc33856dfad21897 (patch) | |
tree | 6fd7f6e79bf2baac4395c88e9a4f17ec3c72b106 /golang/cmd/fatcatd/root.go | |
parent | c4a7f51bbf6e157fbf32ef93886b935ea11fa0e2 (diff) | |
download | fatcat-6235211860b5b3794dfe9e64bc33856dfad21897.tar.gz fatcat-6235211860b5b3794dfe9e64bc33856dfad21897.zip |
cleanups
Diffstat (limited to 'golang/cmd/fatcatd/root.go')
-rw-r--r-- | golang/cmd/fatcatd/root.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/golang/cmd/fatcatd/root.go b/golang/cmd/fatcatd/root.go index d4c7f161..b5263b06 100644 --- a/golang/cmd/fatcatd/root.go +++ b/golang/cmd/fatcatd/root.go @@ -6,7 +6,6 @@ import ( "fmt" log "github.com/sirupsen/logrus" - //middleware "github.com/go-openapi/runtime/middleware" "github.com/spf13/viper" "github.com/spf13/cobra" "github.com/getsentry/raven-go" @@ -25,18 +24,20 @@ func init() { cobra.OnInitialize(initConfig) rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is ./fatcatd.toml)") rootCmd.PersistentFlags().BoolP("verbose", "v", false, "increase logging volume") + viper.BindPFlag("verbose", rootCmd.PersistentFlags().Lookup("verbose")) + + serveCmd.Flags().String("db-url", "postgres://", "database connecion string") rootCmd.AddCommand(serveCmd) } func initConfig() { - viper.SetDefault("port", 9411) - viper.SetDefault("verbose", true) + viper.SetDefault("port", 9411) + viper.SetDefault("db_url", "postgres://bnewbold@localhost/fatcat") viper.SetEnvPrefix("FATCAT") viper.AutomaticEnv() - if cfgFile != "" { // Use config file from the flag. viper.SetConfigFile(cfgFile) @@ -54,6 +55,11 @@ func initConfig() { // not default of stderr log.SetOutput(os.Stdout); + if viper.GetBool("verbose") == true { + log.SetLevel(log.DebugLevel) + } + log.Debug("It's verbose!") + raven.SetDSN(viper.GetString("sentry_dsn")); } |