// ConfigAction read config at first
ConfigAction read config at first
// ConfigAction read config at first
func ConfigAction(f cli.ActionFunc) cli.ActionFunc {
	viper.SetEnvPrefix(reflect.TypeOf(Main).String())
	viper.BindEnv("env")
	viper.SetConfigName("config")
	viper.SetConfigType("toml")
	viper.AddConfigPath(".")
	return func(c *cli.Context) error {
		if err := viper.ReadInConfig(); err != nil {
			return err
		}
		if MODE() == PRODUCTION {
			log.SetLevel(log.InfoLevel)
			wrt, err := syslog.New(syslog.LOG_INFO, viper.GetString("server.name"))
			if err != nil {
				return err
			}
			log.AddHook(&logrus_syslog.SyslogHook{Writer: wrt})
		} else {
			log.SetLevel(log.DebugLevel)
		}
		log.Infof("read config from %s", viper.ConfigFileUsed())
		return f(c)
	}
}
func ConfigAction ( f cli . ActionFunc ) cli . ActionFunc { viper . SetEnvPrefix ( reflect . TypeOf ( Main ) . String ( ) ) viper . BindEnv ( " " ) viper . SetConfigName ( " " ) viper . SetConfigType ( " " ) viper . AddConfigPath ( " " ) return func ( c * cli . Context ) error { if err := viper . ReadInConfig ( ) ; err != nil { return err } if MODE ( ) == PRODUCTION { log . SetLevel ( log . InfoLevel ) wrt , err := syslog . New ( syslog . LOG_INFO , viper . GetString ( " " ) ) if err != nil { return err } log . AddHook ( & logrus_syslog . SyslogHook { Writer : wrt } ) } else { log . SetLevel ( log . DebugLevel ) } log . Infof ( " " , viper . ConfigFileUsed ( ) ) return f ( c ) } }
ConfigAction read config at first
ConfigAction read config at first
// ----------