[VOL-2357]openolt adapter log_level command line argument should take log level names not int value
Change-Id: I63b94c5c546a11a6612f09fec6e0658633c96351
diff --git a/config/config.go b/config/config.go
index b763621..0095575 100644
--- a/config/config.go
+++ b/config/config.go
@@ -37,7 +37,7 @@
defaultKvstoretimeout = 5 //in seconds
defaultKvstorehost = "127.0.0.1"
defaultKvstoreport = 2379 // Consul = 8500; Etcd = 2379
- defaultLoglevel = 0
+ defaultLoglevel = "DEBUG"
defaultBanner = false
defaultDisplayVersionOnly = false
defaultTopic = "openolt"
@@ -71,7 +71,7 @@
Topic string
CoreTopic string
EventTopic string
- LogLevel int
+ LogLevel string
OnuNumber int
Banner bool
DisplayVersionOnly bool
@@ -155,7 +155,7 @@
flag.IntVar(&(so.KVStorePort), "kv_store_port", defaultKvstoreport, help)
help = fmt.Sprintf("Log level")
- flag.IntVar(&(so.LogLevel), "log_level", defaultLoglevel, help)
+ flag.StringVar(&(so.LogLevel), "log_level", defaultLoglevel, help)
help = fmt.Sprintf("Number of ONUs")
flag.IntVar(&(so.OnuNumber), "onu_number", defaultOnunumber, help)
diff --git a/main.go b/main.go
index 9a3b97a..6b07362 100644
--- a/main.go
+++ b/main.go
@@ -444,8 +444,10 @@
// Setup logging
+ loglevel := log.StringToInt(cf.LogLevel)
+
// Setup default logger - applies for packages that do not have specific logger set
- if _, err := log.SetDefaultLogger(log.JSON, cf.LogLevel, log.Fields{"instanceId": cf.InstanceID}); err != nil {
+ if _, err := log.SetDefaultLogger(log.JSON, loglevel, log.Fields{"instanceId": cf.InstanceID}); err != nil {
log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
}