logging level 🐃

This commit is contained in:
Liang Ding 2014-12-13 18:53:48 +08:00
parent cb14485388
commit a750f10401
2 changed files with 10 additions and 3 deletions

View File

@ -253,7 +253,8 @@ func Save() bool {
} }
// Load loads the configurations from wide.json. // Load loads the configurations from wide.json.
func Load(confPath, confIP, confPort, confServer, confStaticServer, confContext, confChannel string, confDocker bool) { func Load(confPath, confIP, confPort, confServer, confLogLevel, confStaticServer, confContext, confChannel string,
confDocker bool) {
bytes, _ := ioutil.ReadFile(confPath) bytes, _ := ioutil.ReadFile(confPath)
err := json.Unmarshal(bytes, &Wide) err := json.Unmarshal(bytes, &Wide)
@ -304,6 +305,11 @@ func Load(confPath, confIP, confPort, confServer, confStaticServer, confContext,
Wide.Server = confServer Wide.Server = confServer
} }
// Logging Level
if "" != confLogLevel {
Wide.LogLevel = confLogLevel
}
// Static Server // Static Server
Wide.StaticServer = strings.Replace(Wide.StaticServer, "{IP}", Wide.IP, 1) Wide.StaticServer = strings.Replace(Wide.StaticServer, "{IP}", Wide.IP, 1)
if "" != confStaticServer { if "" != confStaticServer {

View File

@ -50,12 +50,12 @@ func init() {
confIP := flag.String("ip", "", "ip to visit") confIP := flag.String("ip", "", "ip to visit")
confPort := flag.String("port", "", "port to visit") confPort := flag.String("port", "", "port to visit")
confServer := flag.String("server", "", "this will overwrite Wide.Server if specified") confServer := flag.String("server", "", "this will overwrite Wide.Server if specified")
confLogLevel := flag.String("log_level", "info", "logging level: debug/info/warn/error")
confStaticServer := flag.String("static_server", "", "this will overwrite Wide.StaticServer if specified") confStaticServer := flag.String("static_server", "", "this will overwrite Wide.StaticServer if specified")
confContext := flag.String("context", "", "this will overwrite Wide.Context if specified") confContext := flag.String("context", "", "this will overwrite Wide.Context if specified")
confChannel := flag.String("channel", "", "this will overwrite Wide.XXXChannel if specified") confChannel := flag.String("channel", "", "this will overwrite Wide.XXXChannel if specified")
confStat := flag.Bool("stat", false, "whether report statistics periodically") confStat := flag.Bool("stat", false, "whether report statistics periodically")
confDocker := flag.Bool("docker", false, "whether run in a docker container") confDocker := flag.Bool("docker", false, "whether run in a docker container")
// confLogLevel := flag.String("log_level", "info", "logging level: debug/info/warn/error")
flag.Parse() flag.Parse()
@ -73,7 +73,8 @@ func init() {
event.Load() event.Load()
conf.Load(*confPath, *confIP, *confPort, *confServer, *confStaticServer, *confContext, *confChannel, *confDocker) conf.Load(*confPath, *confIP, *confPort, *confServer, *confLogLevel, *confStaticServer, *confContext, *confChannel,
*confDocker)
conf.FixedTimeCheckEnv() conf.FixedTimeCheckEnv()
conf.FixedTimeSave() conf.FixedTimeSave()