sunty
2024-05-27 6597287fc412ce914aba41fe571ed05817cf371c
config/config.go
@@ -15,10 +15,12 @@
}
type database struct {
   Driver string `mapstructure: "driver"`
   Host   string `mapstructure: "host"`
   Port   string `mapstructure: "port"`
   Name   string `mapstructure: "name"`
   Driver   string `mapstructure: "driver"`
   Host     string `mapstructure: "host"`
   Port     string `mapstructure: "port"`
   Name     string `mapstructure: "name"`
   Username string `mapstructure: "username"`
   Password string `mapstructure: "password"`
}
type elastic struct {
@@ -38,10 +40,19 @@
   LogLevel string `mapstructure: "logLevel"`
}
type api struct {
   Host      string `mapstructure: "host"`
   Port      string `mapstructure: "port"`
   CsTimes   int    `mapstructure:"csTimes"`
   CsHours   int    `mapstructure:"csHours"`
   AInterval int    `mapstructure:"aInterval"`
}
var LogConf = &LogConfig{}
var DataBase = &database{}
var Elastic = &elastic{}
var App = &app{}
var Api = &api{}
var LogBasePath string
var LogLevel int
@@ -57,6 +68,7 @@
   viper.UnmarshalKey("elastic", Elastic)
   viper.UnmarshalKey("database", DataBase)
   viper.UnmarshalKey("app", App)
   viper.UnmarshalKey("api", Api)
   viper.UnmarshalKey("log", LogConf)
   logger.SetLevel(LogConf.Level)
   if viper.GetString("LogBasePath") != "" {