mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-14 02:53:50 +00:00
rename Run to Execute to avoid confusion
This commit is contained in:
parent
bcc97c1906
commit
e1e8a16f97
|
@ -6,5 +6,5 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cmd.Run()
|
cmd.Execute()
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/lestrrat-go/file-rotatelogs"
|
"github.com/lestrrat-go/file-rotatelogs"
|
||||||
"github.com/rifflock/lfshook"
|
"github.com/rifflock/lfshook"
|
||||||
"github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/x-cray/logrus-prefixed-formatter"
|
"github.com/x-cray/logrus-prefixed-formatter"
|
||||||
|
@ -46,7 +46,7 @@ func init() {
|
||||||
RootCmd.PersistentFlags().String("max-api-secret", "", "max api secret")
|
RootCmd.PersistentFlags().String("max-api-secret", "", "max api secret")
|
||||||
}
|
}
|
||||||
|
|
||||||
func Run() {
|
func Execute() {
|
||||||
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
|
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
|
||||||
|
|
||||||
// Enable environment variable binding, the env vars are not overloaded yet.
|
// Enable environment variable binding, the env vars are not overloaded yet.
|
||||||
|
@ -63,23 +63,23 @@ func Run() {
|
||||||
|
|
||||||
err := viper.ReadInConfig()
|
err := viper.ReadInConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Fatal("failed to load config file")
|
log.WithError(err).Fatal("failed to load config file")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Once the flags are defined, we can bind config keys with flags.
|
// Once the flags are defined, we can bind config keys with flags.
|
||||||
if err := viper.BindPFlags(RootCmd.PersistentFlags()); err != nil {
|
if err := viper.BindPFlags(RootCmd.PersistentFlags()); err != nil {
|
||||||
logrus.WithError(err).Errorf("failed to bind persistent flags. please check the flag settings.")
|
log.WithError(err).Errorf("failed to bind persistent flags. please check the flag settings.")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := viper.BindPFlags(RootCmd.Flags()); err != nil {
|
if err := viper.BindPFlags(RootCmd.Flags()); err != nil {
|
||||||
logrus.WithError(err).Errorf("failed to bind local flags. please check the flag settings.")
|
log.WithError(err).Errorf("failed to bind local flags. please check the flag settings.")
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.SetFormatter(&prefixed.TextFormatter{})
|
log.SetFormatter(&prefixed.TextFormatter{})
|
||||||
|
|
||||||
logger := logrus.StandardLogger()
|
logger := log.StandardLogger()
|
||||||
if viper.GetBool("debug") {
|
if viper.GetBool("debug") {
|
||||||
logger.SetLevel(logrus.DebugLevel)
|
logger.SetLevel(log.DebugLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
environment := os.Getenv("BBGO_ENV")
|
environment := os.Getenv("BBGO_ENV")
|
||||||
|
@ -93,23 +93,23 @@ func Run() {
|
||||||
rotatelogs.WithRotationTime(time.Duration(24)*time.Hour),
|
rotatelogs.WithRotationTime(time.Duration(24)*time.Hour),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Panic(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
logger.AddHook(
|
logger.AddHook(
|
||||||
lfshook.NewHook(
|
lfshook.NewHook(
|
||||||
lfshook.WriterMap{
|
lfshook.WriterMap{
|
||||||
logrus.DebugLevel: writer,
|
log.DebugLevel: writer,
|
||||||
logrus.InfoLevel: writer,
|
log.InfoLevel: writer,
|
||||||
logrus.WarnLevel: writer,
|
log.WarnLevel: writer,
|
||||||
logrus.ErrorLevel: writer,
|
log.ErrorLevel: writer,
|
||||||
logrus.FatalLevel: writer,
|
log.FatalLevel: writer,
|
||||||
},
|
},
|
||||||
&logrus.JSONFormatter{},
|
&log.JSONFormatter{},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := RootCmd.Execute(); err != nil {
|
if err := RootCmd.Execute(); err != nil {
|
||||||
logrus.WithError(err).Fatalf("cannot execute command")
|
log.WithError(err).Fatalf("cannot execute command")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user