Skip to content

Commit

Permalink
[FAB-6108] Make logging package names consistent
Browse files Browse the repository at this point in the history
See JIRA for more info.

Change-Id: I4dd0d48b7548820fa096a1c4f4f72ad9dcdb48ee
Signed-off-by: Kostas Christidis <kostas@christidis.io>
  • Loading branch information
kchristidis committed Sep 12, 2017
1 parent bd23071 commit 2512861
Show file tree
Hide file tree
Showing 29 changed files with 134 additions and 57 deletions.
9 changes: 8 additions & 1 deletion orderer/common/blockcutter/blockcutter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ import (
"github.com/hyperledger/fabric/common/channelconfig"
cb "github.com/hyperledger/fabric/protos/common"

"github.com/hyperledger/fabric/common/flogging"
"github.com/op/go-logging"
)

var logger = logging.MustGetLogger("orderer/common/blockcutter")
const pkgLogID = "orderer/common/blockcutter"

var logger *logging.Logger

func init() {
logger = flogging.MustGetLogger(pkgLogID)
}

// Receiver defines a sink for the ordered broadcast messages
type Receiver interface {
Expand Down
4 changes: 2 additions & 2 deletions orderer/common/blockcutter/blockcutter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import (
cb "github.com/hyperledger/fabric/protos/common"
ab "github.com/hyperledger/fabric/protos/orderer"

logging "github.com/op/go-logging"
"github.com/hyperledger/fabric/common/flogging"
"github.com/stretchr/testify/assert"
)

func init() {
logging.SetLevel(logging.DEBUG, "")
flogging.SetModuleLevel(pkgLogID, "DEBUG")
}

var tx = &cb.Envelope{Payload: []byte("GOOD")}
Expand Down
13 changes: 9 additions & 4 deletions orderer/common/broadcast/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package broadcast
import (
"io"

"github.com/hyperledger/fabric/common/flogging"
"github.com/hyperledger/fabric/orderer/common/msgprocessor"
cb "github.com/hyperledger/fabric/protos/common"
ab "github.com/hyperledger/fabric/protos/orderer"
Expand All @@ -18,7 +19,13 @@ import (
"github.com/pkg/errors"
)

var logger = logging.MustGetLogger("orderer/common/broadcast")
const pkgLogID = "orderer/common/broadcast"

var logger *logging.Logger

func init() {
logger = flogging.MustGetLogger(pkgLogID)
}

// Handler defines an interface which handles broadcasts
type Handler interface {
Expand Down Expand Up @@ -113,9 +120,7 @@ func (bh *handlerImpl) Handle(srv ab.AtomicBroadcast_BroadcastServer) error {
}
}

if logger.IsEnabledFor(logging.DEBUG) {
logger.Debugf("[channel: %s] Broadcast has successfully enqueued message of type %s from %s", chdr.ChannelId, cb.HeaderType_name[chdr.Type], addr)
}
logger.Debugf("[channel: %s] Broadcast has successfully enqueued message of type %s from %s", chdr.ChannelId, cb.HeaderType_name[chdr.Type], addr)

err = srv.Send(&ab.BroadcastResponse{Status: cb.Status_SUCCESS})
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions orderer/common/broadcast/broadcast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
"testing"
"time"

"github.com/hyperledger/fabric/common/flogging"
"github.com/hyperledger/fabric/orderer/common/msgprocessor"
cb "github.com/hyperledger/fabric/protos/common"
ab "github.com/hyperledger/fabric/protos/orderer"
logging "github.com/op/go-logging"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
Expand All @@ -24,7 +24,7 @@ import (
)

func init() {
logging.SetLevel(logging.DEBUG, "")
flogging.SetModuleLevel(pkgLogID, "DEBUG")
}

type mockStream struct {
Expand Down
9 changes: 8 additions & 1 deletion orderer/common/deliver/deliver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package deliver
import (
"io"

"github.com/hyperledger/fabric/common/flogging"
"github.com/hyperledger/fabric/common/policies"
"github.com/hyperledger/fabric/orderer/common/ledger"
"github.com/hyperledger/fabric/orderer/common/msgprocessor"
Expand All @@ -31,7 +32,13 @@ import (
"github.com/hyperledger/fabric/protos/utils"
)

var logger = logging.MustGetLogger("orderer/common/deliver")
const pkgLogID = "orderer/common/deliver"

var logger *logging.Logger

func init() {
logger = flogging.MustGetLogger(pkgLogID)
}

// Handler defines an interface which handles Deliver requests
type Handler interface {
Expand Down
4 changes: 2 additions & 2 deletions orderer/common/deliver/deliver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"testing"
"time"

"github.com/hyperledger/fabric/common/flogging"
mockpolicies "github.com/hyperledger/fabric/common/mocks/policies"
"github.com/hyperledger/fabric/common/policies"
"github.com/hyperledger/fabric/common/tools/configtxgen/provisional"
Expand All @@ -30,7 +31,6 @@ import (
cb "github.com/hyperledger/fabric/protos/common"
ab "github.com/hyperledger/fabric/protos/orderer"
"github.com/hyperledger/fabric/protos/utils"
logging "github.com/op/go-logging"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
"google.golang.org/grpc"
Expand All @@ -44,7 +44,7 @@ var systemChainID = "systemChain"
const ledgerSize = 10

func init() {
logging.SetLevel(logging.DEBUG, "")
flogging.SetModuleLevel(pkgLogID, "DEBUG")
}

type mockStream struct {
Expand Down
7 changes: 6 additions & 1 deletion orderer/common/ledger/file/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package fileledger

import (
"github.com/hyperledger/fabric/common/flogging"
cl "github.com/hyperledger/fabric/common/ledger"
"github.com/hyperledger/fabric/common/ledger/blkstorage"
ledger "github.com/hyperledger/fabric/orderer/common/ledger"
Expand All @@ -25,10 +26,14 @@ import (
"github.com/op/go-logging"
)

var logger = logging.MustGetLogger("orderer/fileledger")
const pkgLogID = "orderer/ledger/fileledger"

var logger *logging.Logger

var closedChan chan struct{}

func init() {
logger = flogging.MustGetLogger(pkgLogID)
closedChan = make(chan struct{})
close(closedChan)
}
Expand Down
4 changes: 2 additions & 2 deletions orderer/common/ledger/file/impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ import (
"os"
"testing"

"github.com/hyperledger/fabric/common/flogging"
cl "github.com/hyperledger/fabric/common/ledger"
"github.com/hyperledger/fabric/common/tools/configtxgen/provisional"
"github.com/hyperledger/fabric/orderer/common/ledger"
cb "github.com/hyperledger/fabric/protos/common"
ab "github.com/hyperledger/fabric/protos/orderer"
"github.com/hyperledger/fabric/protos/peer"
logging "github.com/op/go-logging"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)

var genesisBlock = cb.NewBlock(0, nil)

func init() {
logging.SetLevel(logging.DEBUG, "")
flogging.SetModuleLevel(pkgLogID, "DEBUG")
}

type testEnv struct {
Expand Down
6 changes: 5 additions & 1 deletion orderer/common/ledger/json/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"path/filepath"
"sync"

"github.com/hyperledger/fabric/common/flogging"
ledger "github.com/hyperledger/fabric/orderer/common/ledger"
cb "github.com/hyperledger/fabric/protos/common"
ab "github.com/hyperledger/fabric/protos/orderer"
Expand All @@ -31,11 +32,14 @@ import (
"github.com/golang/protobuf/jsonpb"
)

var logger = logging.MustGetLogger("orderer/jsonledger")
const pkgLogID = "orderer/ledger/jsonledger"

var logger *logging.Logger
var closedChan chan struct{}
var fileLock sync.Mutex

func init() {
logger = flogging.MustGetLogger(pkgLogID)
closedChan = make(chan struct{})
close(closedChan)
}
Expand Down
4 changes: 2 additions & 2 deletions orderer/common/ledger/json/impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ import (
"testing"
"time"

"github.com/hyperledger/fabric/common/flogging"
"github.com/hyperledger/fabric/common/tools/configtxgen/provisional"
"github.com/hyperledger/fabric/orderer/common/ledger"
cb "github.com/hyperledger/fabric/protos/common"
ab "github.com/hyperledger/fabric/protos/orderer"

logging "github.com/op/go-logging"
"github.com/stretchr/testify/assert"
)

var genesisBlock = cb.NewBlock(0, nil)

func init() {
logging.SetLevel(logging.DEBUG, "")
flogging.SetModuleLevel(pkgLogID, "DEBUG")
}

type testEnv struct {
Expand Down
9 changes: 8 additions & 1 deletion orderer/common/ledger/ram/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,20 @@ import (
"bytes"
"fmt"

"github.com/hyperledger/fabric/common/flogging"
"github.com/hyperledger/fabric/orderer/common/ledger"
cb "github.com/hyperledger/fabric/protos/common"
ab "github.com/hyperledger/fabric/protos/orderer"
"github.com/op/go-logging"
)

var logger = logging.MustGetLogger("orderer/ramledger")
const pkgLogID = "orderer/ledger/ramledger"

var logger *logging.Logger

func init() {
logger = flogging.MustGetLogger(pkgLogID)
}

type cursor struct {
list *simpleList
Expand Down
5 changes: 2 additions & 3 deletions orderer/common/ledger/ram/impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@ package ramledger
import (
"testing"

"github.com/hyperledger/fabric/common/flogging"
"github.com/hyperledger/fabric/common/tools/configtxgen/provisional"
"github.com/hyperledger/fabric/orderer/common/ledger"
cb "github.com/hyperledger/fabric/protos/common"
ab "github.com/hyperledger/fabric/protos/orderer"

logging "github.com/op/go-logging"
)

var genesisBlock = cb.NewBlock(0, nil)

func init() {
logging.SetLevel(logging.DEBUG, "")
flogging.SetModuleLevel(pkgLogID, "DEBUG")
}

func newTestChain(maxSize int) *ramLedger {
Expand Down
4 changes: 2 additions & 2 deletions orderer/common/localconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
)

const (
pkgLogID = "orderer/common/localconfig"
pkgLogID = "orderer/common/config"

// Prefix identifies the prefix for the orderer-related ENV vars.
Prefix = "ORDERER"
Expand All @@ -50,7 +50,7 @@ var (

func init() {
logger = flogging.MustGetLogger(pkgLogID)
flogging.SetModuleLevel(pkgLogID, "error")
flogging.SetModuleLevel(pkgLogID, "ERROR")

configName = strings.ToLower(Prefix)
}
Expand Down
5 changes: 5 additions & 0 deletions orderer/common/localconfig/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ import (
"testing"
"time"

"github.com/hyperledger/fabric/common/flogging"
"github.com/hyperledger/fabric/common/tools/configtxgen/provisional"
"github.com/stretchr/testify/assert"
)

func init() {
flogging.SetModuleLevel(pkgLogID, "DEBUG")
}

func TestGoodConfig(t *testing.T) {
assert.NotNil(t, Load(), "Could not load config")
}
Expand Down
11 changes: 9 additions & 2 deletions orderer/common/msgprocessor/msgprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,23 @@ import (

"github.com/hyperledger/fabric/common/flogging"
cb "github.com/hyperledger/fabric/protos/common"
logging "github.com/op/go-logging"
)

var logger = flogging.MustGetLogger("common/msgprocessor")

const (
pkgLogID = "orderer/common/msgprocessor"

// These should eventually be derived from the channel support once enabled
msgVersion = int32(0)
epoch = 0
)

var logger *logging.Logger

func init() {
logger = flogging.MustGetLogger(pkgLogID)
}

// ErrChannelDoesNotExist is returned by the system channel for transactions which
// are not for the system channel ID and are not attempting to create a new channel
var ErrChannelDoesNotExist = errors.New("channel does not exist")
Expand Down
4 changes: 2 additions & 2 deletions orderer/common/msgprocessor/sigfilter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import (
"fmt"
"testing"

"github.com/hyperledger/fabric/common/flogging"
mockpolicies "github.com/hyperledger/fabric/common/mocks/policies"
cb "github.com/hyperledger/fabric/protos/common"
"github.com/hyperledger/fabric/protos/utils"

"github.com/op/go-logging"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
)

func init() {
logging.SetLevel(logging.DEBUG, "")
flogging.SetModuleLevel(pkgLogID, "DEBUG")
}

func makeEnvelope() *cb.Envelope {
Expand Down
11 changes: 9 additions & 2 deletions orderer/common/multichannel/registrar.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/hyperledger/fabric/common/channelconfig"
"github.com/hyperledger/fabric/common/configtx"
configtxapi "github.com/hyperledger/fabric/common/configtx/api"
"github.com/hyperledger/fabric/common/flogging"
"github.com/hyperledger/fabric/orderer/common/ledger"
"github.com/hyperledger/fabric/orderer/common/msgprocessor"
"github.com/hyperledger/fabric/orderer/consensus"
Expand All @@ -26,13 +27,19 @@ import (
"github.com/hyperledger/fabric/common/crypto"
)

var logger = logging.MustGetLogger("orderer/multichannel")

const (
pkgLogID = "orderer/commmon/multichannel"

msgVersion = int32(0)
epoch = 0
)

var logger *logging.Logger

func init() {
logger = flogging.MustGetLogger(pkgLogID)
}

type mutableResources interface {
channelconfig.Resources
Update(*channelconfig.Bundle)
Expand Down
Loading

0 comments on commit 2512861

Please sign in to comment.