Skip to content

Commit 7132dd5

Browse files
committed
[FAB-2351] Update loggers to flogging.MustGetLogger
This CR updates all loggers throughout the code base to use `flogging.MustGetLogger`. This function wraps `logging.MustGetLogger` and tracks the logger modules defined in the system. This enables the ability to set log levels for modules using regular expressions. and make it easy to change the levels for any module and all its submodules with a single command (e.g. gossip, ledger, msp). Change-Id: If5d3229ea2312adb56fc21bfdafbed3d967cf1df Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
1 parent 95d13d2 commit 7132dd5

File tree

69 files changed

+191
-195
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+191
-195
lines changed

bccsp/factory/factory.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"sync"
2121

2222
"github.com/hyperledger/fabric/bccsp"
23-
"github.com/op/go-logging"
23+
"github.com/hyperledger/fabric/common/flogging"
2424
)
2525

2626
var (
@@ -41,7 +41,7 @@ var (
4141
// Factories' Initialization Error
4242
factoriesInitError error
4343

44-
logger = logging.MustGetLogger("bccsp")
44+
logger = flogging.MustGetLogger("bccsp")
4545
)
4646

4747
// BCCSPFactory is used to get instances of the BCCSP interface.

bccsp/pkcs11/impl.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ import (
3232

3333
"github.com/hyperledger/fabric/bccsp"
3434
"github.com/hyperledger/fabric/bccsp/utils"
35+
"github.com/hyperledger/fabric/common/flogging"
3536
"github.com/miekg/pkcs11"
36-
"github.com/op/go-logging"
37+
3738
"golang.org/x/crypto/sha3"
3839
)
3940

4041
var (
41-
logger = logging.MustGetLogger("bccsp_p11")
42+
logger = flogging.MustGetLogger("bccsp_p11")
4243
sessionCacheSize = 10
4344
)
4445

bccsp/sw/impl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ import (
3636

3737
"github.com/hyperledger/fabric/bccsp"
3838
"github.com/hyperledger/fabric/bccsp/utils"
39-
"github.com/op/go-logging"
39+
"github.com/hyperledger/fabric/common/flogging"
4040
"golang.org/x/crypto/sha3"
4141
)
4242

4343
var (
44-
logger = logging.MustGetLogger("bccsp_sw")
44+
logger = flogging.MustGetLogger("bccsp_sw")
4545
)
4646

4747
// NewDefaultSecurityLevel returns a new instance of the software-based BCCSP

common/cauthdsl/cauthdsl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ package cauthdsl
1919
import (
2020
"fmt"
2121

22+
"github.com/hyperledger/fabric/common/flogging"
2223
"github.com/hyperledger/fabric/msp"
2324
cb "github.com/hyperledger/fabric/protos/common"
2425
mb "github.com/hyperledger/fabric/protos/msp"
25-
"github.com/op/go-logging"
2626
)
2727

28-
var cauthdslLogger = logging.MustGetLogger("cauthdsl")
28+
var cauthdslLogger = flogging.MustGetLogger("cauthdsl")
2929

3030
// compile recursively builds a go evaluatable function corresponding to the policy specified
3131
func compile(policy *cb.SignaturePolicy, identities []*mb.MSPPrincipal, deserializer msp.IdentityDeserializer) (func([]*cb.SignedData, []bool) bool, error) {

common/config/msp/config_util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import (
2323
mspprotos "github.com/hyperledger/fabric/protos/msp"
2424
"github.com/hyperledger/fabric/protos/utils"
2525

26-
logging "github.com/op/go-logging"
26+
"github.com/hyperledger/fabric/common/flogging"
2727
)
2828

29-
var logger = logging.MustGetLogger("configvalues/msp")
29+
var logger = flogging.MustGetLogger("configvalues/msp")
3030

3131
const (
3232
// ReadersPolicyKey is the key used for the read policy

common/config/proposer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ import (
2121
"sync"
2222

2323
"github.com/golang/protobuf/proto"
24-
logging "github.com/op/go-logging"
24+
"github.com/hyperledger/fabric/common/flogging"
2525
)
2626

27-
var logger = logging.MustGetLogger("common/config")
27+
var logger = flogging.MustGetLogger("common/config")
2828

2929
// ValueDeserializer provides a mechanism to retrieve proto messages to deserialize config values into
3030
type ValueDeserializer interface {

common/configtx/manager.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ import (
2222
"regexp"
2323

2424
"github.com/hyperledger/fabric/common/configtx/api"
25+
"github.com/hyperledger/fabric/common/flogging"
2526
cb "github.com/hyperledger/fabric/protos/common"
2627
"github.com/hyperledger/fabric/protos/utils"
27-
28-
logging "github.com/op/go-logging"
2928
)
3029

31-
var logger = logging.MustGetLogger("common/configtx")
30+
var logger = flogging.MustGetLogger("common/configtx")
3231

3332
// Constraints for valid chain IDs
3433
var (

common/configtx/test/helper.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@ import (
2525
"github.com/hyperledger/fabric/common/configtx"
2626
genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig"
2727
"github.com/hyperledger/fabric/common/configtx/tool/provisional"
28+
"github.com/hyperledger/fabric/common/flogging"
2829
"github.com/hyperledger/fabric/common/genesis"
2930
"github.com/hyperledger/fabric/msp"
3031
cb "github.com/hyperledger/fabric/protos/common"
3132
mspproto "github.com/hyperledger/fabric/protos/msp"
32-
33-
logging "github.com/op/go-logging"
3433
)
3534

36-
var logger = logging.MustGetLogger("common/configtx/test")
35+
var logger = flogging.MustGetLogger("common/configtx/test")
3736

3837
const (
3938
// AcceptAllPolicyKey is the key of the AcceptAllPolicy.

common/configtx/tool/configtxgen/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/hyperledger/fabric/common/configtx"
2828
genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig"
2929
"github.com/hyperledger/fabric/common/configtx/tool/provisional"
30+
"github.com/hyperledger/fabric/common/flogging"
3031
"github.com/hyperledger/fabric/msp"
3132
cb "github.com/hyperledger/fabric/protos/common"
3233
"github.com/hyperledger/fabric/protos/utils"
@@ -35,7 +36,7 @@ import (
3536
logging "github.com/op/go-logging"
3637
)
3738

38-
var logger = logging.MustGetLogger("common/configtx/tool")
39+
var logger = flogging.MustGetLogger("common/configtx/tool")
3940

4041
func doOutputBlock(pgen provisional.Generator, channelID string, outputBlock string) error {
4142
logger.Info("Generating genesis block")

common/configtx/tool/localconfig/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ import (
2323
"strings"
2424
"time"
2525

26+
"github.com/hyperledger/fabric/common/flogging"
2627
"github.com/hyperledger/fabric/common/viperutil"
2728

28-
"github.com/op/go-logging"
2929
"github.com/spf13/viper"
3030

3131
bccsp "github.com/hyperledger/fabric/bccsp/factory"
3232
)
3333

34-
var logger = logging.MustGetLogger("configtx/tool/localconfig")
34+
var logger = flogging.MustGetLogger("configtx/tool/localconfig")
3535

3636
const (
3737
// SampleInsecureProfile references the sample profile which does not include any MSPs and uses solo for ordering.

0 commit comments

Comments
 (0)