aboutsummaryrefslogtreecommitdiffstats
path: root/golang/cmd/fatcatd/root.go
diff options
context:
space:
mode:
Diffstat (limited to 'golang/cmd/fatcatd/root.go')
-rw-r--r--golang/cmd/fatcatd/root.go14
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"));
}