3 Star 6 Fork 7

Gitee 极速下载/Hyperledger fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/hyperledger/fabric
克隆/下载
logging.go 2.04 KB
一键复制 编辑 原始数据 按行查看 历史
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package util
import (
"sync"
"github.com/hyperledger/fabric/common/flogging"
"go.uber.org/zap/zapcore"
)
// Logger names for logger initialization.
const (
ChannelLogger = "gossip.channel"
CommLogger = "gossip.comm"
DiscoveryLogger = "gossip.discovery"
ElectionLogger = "gossip.election"
GossipLogger = "gossip.gossip"
CommMockLogger = "gossip.comm.mock"
PullLogger = "gossip.pull"
ServiceLogger = "gossip.service"
StateLogger = "gossip.state"
PrivateDataLogger = "gossip.privdata"
)
var loggers = make(map[string]Logger)
var lock = sync.Mutex{}
var testMode bool
// defaultTestSpec is the default logging level for gossip tests
var defaultTestSpec = "WARNING"
type Logger interface {
Debug(args ...interface{})
Debugf(format string, args ...interface{})
Error(args ...interface{})
Errorf(format string, args ...interface{})
Fatal(args ...interface{})
Fatalf(format string, args ...interface{})
Info(args ...interface{})
Infof(format string, args ...interface{})
Panic(args ...interface{})
Panicf(format string, args ...interface{})
Warning(args ...interface{})
Warningf(format string, args ...interface{})
IsEnabledFor(l zapcore.Level) bool
With(args ...interface{}) *flogging.FabricLogger
}
// GetLogger returns a logger for given gossip logger name and peerID
func GetLogger(name string, peerID string) Logger {
if peerID != "" && testMode {
name = name + "#" + peerID
}
lock.Lock()
defer lock.Unlock()
if lgr, ok := loggers[name]; ok {
return lgr
}
// Logger doesn't exist, create a new one
lgr := flogging.MustGetLogger(name)
loggers[name] = lgr
return lgr
}
// SetupTestLogging sets the default log levels for gossip unit tests to defaultTestSpec
func SetupTestLogging() {
SetupTestLoggingWithLevel(defaultTestSpec)
}
// SetupTestLoggingWithLevel sets the default log levels for gossip unit tests to level
func SetupTestLoggingWithLevel(level string) {
testMode = true
flogging.ActivateSpec(level)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors/fabric.git
git@gitee.com:mirrors/fabric.git
mirrors
fabric
Hyperledger fabric
v2.1.1

搜索帮助