[VOL-2356]core log_level command line argument should take log level names not int value

Change-Id: Ifc9ca5aa6d2b40e068e0ecad845a788edad0a3a1
diff --git a/rw_core/config/config.go b/rw_core/config/config.go
index 0ffe807..0c2c3ce 100644
--- a/rw_core/config/config.go
+++ b/rw_core/config/config.go
@@ -41,7 +41,7 @@
 	defaultKVStorePort               = 2379 // Consul = 8500; Etcd = 2379
 	defaultKVTxnKeyDelTime           = 60
 	defaultKVStoreDataPrefix         = "service/voltha"
-	defaultLogLevel                  = 0
+	defaultLogLevel                  = "DEBUG"
 	defaultBanner                    = false
 	defaultDisplayVersionOnly        = false
 	defaultCoreTopic                 = "rwcore"
@@ -81,7 +81,7 @@
 	KVTxnKeyDelTime           int
 	KVStoreDataPrefix         string
 	CoreTopic                 string
-	LogLevel                  int
+	LogLevel                  string
 	Banner                    bool
 	DisplayVersionOnly        bool
 	RWCoreKey                 string
@@ -201,7 +201,7 @@
 	flag.StringVar(&(cf.KVStoreDataPrefix), "kv_store_data_prefix", defaultKVStoreDataPrefix, help)
 
 	help = fmt.Sprintf("Log level")
-	flag.IntVar(&(cf.LogLevel), "log_level", defaultLogLevel, help)
+	flag.StringVar(&(cf.LogLevel), "log_level", defaultLogLevel, help)
 
 	help = fmt.Sprintf("Timeout for long running request")
 	flag.Int64Var(&(cf.LongRunningRequestTimeout), "timeout_long_request", defaultLongRunningRequestTimeout, help)
diff --git a/rw_core/core/grpc_nbi_api_handler.go b/rw_core/core/grpc_nbi_api_handler.go
index c0678a3..27ebb58 100755
--- a/rw_core/core/grpc_nbi_api_handler.go
+++ b/rw_core/core/grpc_nbi_api_handler.go
@@ -191,12 +191,12 @@
 	log.Debugw("UpdateLogLevel-request", log.Fields{"package": logging.PackageName, "intval": int(logging.Level)})
 
 	if logging.PackageName == "" {
-		log.SetAllLogLevel(int(logging.Level))
-		log.SetDefaultLogLevel(int(logging.Level))
+		log.SetAllLogLevel(log.LogLevel(logging.Level))
+		log.SetDefaultLogLevel(log.LogLevel(logging.Level))
 	} else if logging.PackageName == "default" {
-		log.SetDefaultLogLevel(int(logging.Level))
+		log.SetDefaultLogLevel(log.LogLevel(logging.Level))
 	} else {
-		log.SetPackageLogLevel(logging.PackageName, int(logging.Level))
+		log.SetPackageLogLevel(logging.PackageName, log.LogLevel(logging.Level))
 	}
 
 	return &empty.Empty{}, nil
diff --git a/rw_core/main.go b/rw_core/main.go
index 71f64f3..e8a7ea6 100644
--- a/rw_core/main.go
+++ b/rw_core/main.go
@@ -223,9 +223,16 @@
 	} else {
 		log.Fatal("HOSTNAME not set")
 	}
+
 	realMain()
+
+	logLevel, err := log.StringToLogLevel(cf.LogLevel)
+	if err != nil {
+		panic(err)
+	}
+
 	//Setup default logger - applies for packages that do not have specific logger set
-	if _, err := log.SetDefaultLogger(log.JSON, cf.LogLevel, log.Fields{"instanceId": instanceID}); err != nil {
+	if _, err := log.SetDefaultLogger(log.JSON, logLevel, log.Fields{"instanceId": instanceID}); err != nil {
 		log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
 	}
 
@@ -235,7 +242,7 @@
 	}
 
 	// Update all loggers to log level specified as input parameter
-	log.SetAllLogLevel(cf.LogLevel)
+	log.SetAllLogLevel(logLevel)
 
 	//log.SetPackageLogLevel("github.com/opencord/voltha-go/rw_core/core", log.DebugLevel)