Merge pull request #159 from docker/parse_log_level

parse string log level from config
This commit is contained in:
Nathan McCauley 2015-07-29 15:56:59 -07:00
commit 07c97577da
3 changed files with 8 additions and 3 deletions

View File

@ -8,7 +8,7 @@
"port": "7899", "port": "7899",
"tls_ca_file": "./fixtures/root-ca.crt" }, "tls_ca_file": "./fixtures/root-ca.crt" },
"logging": { "logging": {
"level": 5 "level": "debug"
}, },
"storage": { "storage": {
"backend": "mysql", "backend": "mysql",

View File

@ -10,7 +10,7 @@
"port": "" "port": ""
}, },
"logging": { "logging": {
"level": 5 "level": "debug"
}, },
"storage": { "storage": {
"backend": "mysql", "backend": "mysql",

View File

@ -64,7 +64,12 @@ func main() {
logrus.Error("Could not read config at ", configFile) logrus.Error("Could not read config at ", configFile)
os.Exit(1) os.Exit(1)
} }
logrus.SetLevel(logrus.Level(viper.GetInt("logging.level"))) lvl, err := logrus.ParseLevel(viper.GetString("logging.level"))
if err != nil {
lvl = logrus.ErrorLevel
logrus.Error("Could not parse log level from config. Defaulting to ErrorLevel")
}
logrus.SetLevel(lvl)
sigHup := make(chan os.Signal) sigHup := make(chan os.Signal)
sigTerm := make(chan os.Signal) sigTerm := make(chan os.Signal)