Add dynamic logging capability.

Change-Id: I98de8a6f30d5f82e5e5e902da6df0d8bf1fea889
diff --git a/common/log/log.go b/common/log/log.go
index d751c34..93b2072 100644
--- a/common/log/log.go
+++ b/common/log/log.go
@@ -110,12 +110,14 @@
 	}
 }
 
+var cfg zp.Config
+
 // SetLogger needs to be invoked before the logger API can be invoked.  This function
 // initialize the default logger (zap's sugaredlogger)
 func SetLogger(outputType string, level int, defaultFields Fields) (Logger, error) {
 
 	// Build a custom config using zap
-	cfg := getDefaultConfig(outputType, level, defaultFields)
+	cfg = getDefaultConfig(outputType, level, defaultFields)
 
 	l, err := cfg.Build()
 	if err != nil {
@@ -130,6 +132,25 @@
 	return defaultLogger, nil
 }
 
+func SetLoglevel(level int) {
+	switch level {
+	case DebugLevel:
+		cfg.Level.SetLevel(zc.DebugLevel)
+	case InfoLevel:
+		cfg.Level.SetLevel(zc.InfoLevel)
+	case WarnLevel:
+		cfg.Level.SetLevel(zc.WarnLevel)
+	case ErrorLevel:
+		cfg.Level.SetLevel(zc.ErrorLevel)
+	case PanicLevel:
+		cfg.Level.SetLevel(zc.PanicLevel)
+	case FatalLevel:
+		cfg.Level.SetLevel(zc.FatalLevel)
+	default:
+		cfg.Level.SetLevel(zc.ErrorLevel)
+	}
+}
+
 // CleanUp flushed any buffered log entries. Applications should take care to call
 // CleanUp before exiting.
 func CleanUp() error {
diff --git a/tests/kafka/kafka_inter_container_messaging_test.go b/tests/kafka/kafka_inter_container_messaging_test.go
index 9a73b18..5553d14 100644
--- a/tests/kafka/kafka_inter_container_messaging_test.go
+++ b/tests/kafka/kafka_inter_container_messaging_test.go
@@ -3,6 +3,7 @@
 import (
 	"context"
 	"github.com/golang/protobuf/ptypes"
+	"github.com/google/uuid"
 	"github.com/opencord/voltha-go/common/log"
 	kk "github.com/opencord/voltha-go/kafka"
 	ca "github.com/opencord/voltha-go/protos/core_adapter"
@@ -10,8 +11,6 @@
 	rhp "github.com/opencord/voltha-go/rw_core/core"
 	"github.com/stretchr/testify/assert"
 	"testing"
-	//"time"
-	"github.com/google/uuid"
 	"time"
 )
 
@@ -19,7 +18,7 @@
 var adapterKafkaProxy *kk.KafkaMessagingProxy
 
 func init() {
-	if _, err := log.SetLogger(log.JSON, 1, log.Fields{"instanceId": "testing"}); err != nil {
+	if _, err := log.SetLogger(log.JSON, 3, log.Fields{"instanceId": "testing"}); err != nil {
 		log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
 	}
 	coreKafkaProxy, _ = kk.NewKafkaMessagingProxy(
@@ -80,6 +79,7 @@
 
 func TestMultipleSubscribeUnsubscribe(t *testing.T) {
 	// First subscribe to the specific topic
+	log.SetLoglevel(0)
 	var err error
 	var ch1 <-chan *ca.InterContainerMessage
 	var ch2 <-chan *ca.InterContainerMessage
@@ -118,6 +118,7 @@
 }
 
 func TestIncorrectAPI(t *testing.T) {
+	log.SetLoglevel(3)
 	trnsId := uuid.New().String()
 	protoMsg := &voltha.Device{Id: trnsId}
 	args := make([]*kk.KVArg, 1)