From 855a9d075aa5051c7241e2cfac9ec536a6af116f Mon Sep 17 00:00:00 2001
From: yacovm <yacovm@il.ibm.com>
Date: Tue, 4 Sep 2018 14:43:43 +0300
Subject: [PATCH] [FAB-11852] use Fabric logger in orderer cluster

The cluster code was using the go-logging logger
instead of the flogging.FabricLogger.

Changed it accordingly.

Change-Id: Idcb4f6a593baac78afb50bff5993545d98155356
Signed-off-by: yacovm <yacovm@il.ibm.com>
---
 orderer/common/cluster/comm.go         | 4 ++--
 orderer/common/cluster/comm_test.go    | 4 ++--
 orderer/common/cluster/service.go      | 4 ++--
 orderer/common/cluster/service_test.go | 8 +++++++-
 4 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/orderer/common/cluster/comm.go b/orderer/common/cluster/comm.go
index e70f70cc4..d3d317e19 100644
--- a/orderer/common/cluster/comm.go
+++ b/orderer/common/cluster/comm.go
@@ -14,9 +14,9 @@ import (
 	"time"
 
 	"github.com/golang/protobuf/proto"
+	"github.com/hyperledger/fabric/common/flogging"
 	"github.com/hyperledger/fabric/core/comm"
 	"github.com/hyperledger/fabric/protos/orderer"
-	"github.com/op/go-logging"
 	"github.com/pkg/errors"
 )
 
@@ -80,7 +80,7 @@ type MembersByChannel map[string]MemberMapping
 type Comm struct {
 	shutdown     bool
 	Lock         sync.RWMutex
-	Logger       *logging.Logger
+	Logger       *flogging.FabricLogger
 	ChanExt      ChannelExtractor
 	H            Handler
 	Connections  *ConnectionStore
diff --git a/orderer/common/cluster/comm_test.go b/orderer/common/cluster/comm_test.go
index c21e2f7ec..bbc099ff4 100644
--- a/orderer/common/cluster/comm_test.go
+++ b/orderer/common/cluster/comm_test.go
@@ -17,12 +17,12 @@ import (
 
 	"github.com/golang/protobuf/proto"
 	"github.com/hyperledger/fabric/common/crypto/tlsgen"
+	"github.com/hyperledger/fabric/common/flogging"
 	comm_utils "github.com/hyperledger/fabric/core/comm"
 	"github.com/hyperledger/fabric/orderer/common/cluster"
 	"github.com/hyperledger/fabric/orderer/common/cluster/mocks"
 	"github.com/hyperledger/fabric/protos/orderer"
 	"github.com/onsi/gomega"
-	"github.com/op/go-logging"
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/mock"
 	"google.golang.org/grpc"
@@ -208,7 +208,7 @@ func newTestNode(t *testing.T) *clusterNode {
 	}
 
 	tstSrv.c = &cluster.Comm{
-		Logger:       logging.MustGetLogger("test"),
+		Logger:       flogging.MustGetLogger("test"),
 		Chan2Members: make(cluster.MembersByChannel),
 		H:            handler,
 		ChanExt:      channelExtractor,
diff --git a/orderer/common/cluster/service.go b/orderer/common/cluster/service.go
index 7c5499f77..e9ee3beb3 100644
--- a/orderer/common/cluster/service.go
+++ b/orderer/common/cluster/service.go
@@ -10,9 +10,9 @@ import (
 	"context"
 	"io"
 
+	"github.com/hyperledger/fabric/common/flogging"
 	"github.com/hyperledger/fabric/common/util"
 	"github.com/hyperledger/fabric/protos/orderer"
-	"github.com/op/go-logging"
 	"google.golang.org/grpc"
 )
 
@@ -37,7 +37,7 @@ type SubmitStream interface {
 // Service defines the raft Service
 type Service struct {
 	Dispatcher Dispatcher
-	Logger     logging.Logger
+	Logger     *flogging.FabricLogger
 }
 
 // Step forwards a message to a raft FSM located in this server
diff --git a/orderer/common/cluster/service_test.go b/orderer/common/cluster/service_test.go
index e3739193d..8cb6e753c 100644
--- a/orderer/common/cluster/service_test.go
+++ b/orderer/common/cluster/service_test.go
@@ -11,6 +11,7 @@ import (
 	"io"
 	"testing"
 
+	"github.com/hyperledger/fabric/common/flogging"
 	"github.com/hyperledger/fabric/core/comm"
 	"github.com/hyperledger/fabric/orderer/common/cluster"
 	"github.com/hyperledger/fabric/orderer/common/cluster/mocks"
@@ -34,6 +35,7 @@ func TestStep(t *testing.T) {
 	dispatcher := &mocks.Dispatcher{}
 
 	svc := &cluster.Service{
+		Logger:     flogging.MustGetLogger("test"),
 		Dispatcher: dispatcher,
 	}
 
@@ -78,6 +80,7 @@ func TestSubmitSuccess(t *testing.T) {
 	})
 
 	svc := &cluster.Service{
+		Logger:     flogging.MustGetLogger("test"),
 		Dispatcher: dispatcher,
 	}
 
@@ -155,6 +158,7 @@ func TestSubmitFailure(t *testing.T) {
 			defer dispatcher.AssertNumberOfCalls(t, "DispatchSubmit", testCase.expectedDispatches)
 			dispatcher.On("DispatchSubmit", mock.Anything, mock.Anything).Return(testCase.dispatchReturns...)
 			svc := &cluster.Service{
+				Logger:     flogging.MustGetLogger("test"),
 				Dispatcher: dispatcher,
 			}
 			err := svc.Submit(stream)
@@ -168,5 +172,7 @@ func TestServiceGRPC(t *testing.T) {
 	// Check that Service correctly implements the gRPC interface
 	srv, err := comm.NewGRPCServer("127.0.0.1:0", comm.ServerConfig{})
 	assert.NoError(t, err)
-	orderer.RegisterClusterServer(srv.Server(), &cluster.Service{})
+	orderer.RegisterClusterServer(srv.Server(), &cluster.Service{
+		Logger: flogging.MustGetLogger("test"),
+	})
 }
-- 
GitLab