3 Star 6 Fork 7

Gitee 极速下载/Hyperledger fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/hyperledger/fabric
克隆/下载
global.go 1.86 KB
一键复制 编辑 原始数据 按行查看 历史
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package flogging
import (
"io"
"go.uber.org/zap/zapcore"
"google.golang.org/grpc/grpclog"
)
const (
defaultFormat = "%{color}%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x}%{color:reset} %{message}"
defaultLevel = zapcore.InfoLevel
)
var Global *Logging
var logger *FabricLogger
func init() {
logging, err := New(Config{})
if err != nil {
panic(err)
}
Global = logging
logger = Global.Logger("flogging")
grpcLogger := Global.ZapLogger("grpc")
grpclog.SetLogger(NewGRPCLogger(grpcLogger))
}
// Init initializes logging with the provided config.
func Init(config Config) {
err := Global.Apply(config)
if err != nil {
panic(err)
}
}
// Reset sets logging to the defaults defined in this package.
//
// Used in tests and in the package init
func Reset() {
Global.Apply(Config{})
}
// LoggerLevel gets the current logging level for the logger with the
// provided name.
func LoggerLevel(loggerName string) string {
return Global.Level(loggerName).String()
}
// MustGetLogger creates a logger with the specified name. If an invalid name
// is provided, the operation will panic.
func MustGetLogger(loggerName string) *FabricLogger {
return Global.Logger(loggerName)
}
// ActivateSpec is used to activate a logging specification.
func ActivateSpec(spec string) {
err := Global.ActivateSpec(spec)
if err != nil {
panic(err)
}
}
// DefaultLevel returns the default log level.
func DefaultLevel() string {
return defaultLevel.String()
}
// SetWriter calls SetWriter returning the previous value
// of the writer.
func SetWriter(w io.Writer) io.Writer {
return Global.SetWriter(w)
}
// SetObserver calls SetObserver returning the previous value
// of the observer.
func SetObserver(observer Observer) Observer {
return Global.SetObserver(observer)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors/fabric.git
git@gitee.com:mirrors/fabric.git
mirrors
fabric
Hyperledger fabric
v2.1.1

搜索帮助