SEBA-448 : Setting BBSIM Debug Level

Change-Id: Ic12cf0e106ffa3a4db5bd5bf5ac3c2d723ebfadd
diff --git a/bbsim.go b/bbsim.go
index 33c6cba..dd68b82 100644
--- a/bbsim.go
+++ b/bbsim.go
@@ -37,7 +37,7 @@
 	// CLI Shows up
 	printBanner()
 	opt := core.GetOptions()
-	logger.Setup(opt.KafkaBroker, "DEBUG")
+	logger.Setup(opt.KafkaBroker, opt.Debuglvl)
 
 	mediator := core.NewMediator(opt)
 
diff --git a/common/logger/logger.go b/common/logger/logger.go
index 444cabb..e3d1e90 100644
--- a/common/logger/logger.go
+++ b/common/logger/logger.go
@@ -32,10 +32,21 @@
 	//logger.SetReportCaller(true)
 	myLogger = logger.WithField("topics", []string{"bbsim.log"})
 
-	// TODO make this configurable via cli arg
-	if level == "DEBUG" {
-		logger.SetLevel(log.DebugLevel)
+	var logLevel log.Level = log.DebugLevel
+	switch level{
+		case "TRACE":
+			logLevel = log.TraceLevel
+		case "INFO":
+			logLevel = log.InfoLevel
+		case "WARN":
+			logLevel = log.WarnLevel
+		case "ERROR":
+			logLevel = log.ErrorLevel
+		default:
+			logLevel = log.DebugLevel
 	}
+	logger.Println("Setting Log Level ", logLevel)
+	logger.SetLevel(logLevel)
 
 	if len(kafkaBroker) > 0 {
 		myLogger.Debug("Setting up kafka integration")
diff --git a/core/mediator.go b/core/mediator.go
index 89715c6..203204f 100644
--- a/core/mediator.go
+++ b/core/mediator.go
@@ -44,6 +44,7 @@
 	intvl_test  int
 	Mode        Mode
 	KafkaBroker string
+	Debuglvl	string
 }
 
 func GetOptions() *option {
@@ -60,12 +61,14 @@
 	intvl_test := flag.Int("V", 1, "Interval each Indication")
 	kafkaBroker := flag.String("k", "", "Kafka broker")
 	o.Mode = DEFAULT
+	debg := flag.String("d", "DEBUG", "Debug Level(TRACE DEBUG INFO WARN ERROR)")
 	flag.Parse()
 	if *modeopt == "aaa" {
 		o.Mode = AAA
 	} else if *modeopt == "both" {
 		o.Mode = BOTH
 	}
+	o.Debuglvl = *debg
 	o.oltid = uint32(*oltid)
 	o.npon = uint32(*npon)
 	o.nonus = uint32(*nonus)
@@ -186,4 +189,4 @@
 		next == device.ONU_INACTIVE {
 	}
 	return nil
-}
\ No newline at end of file
+}