代码拉取完成,页面将自动刷新
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package flogging
import (
"strings"
"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{})
}
// GetLoggerLevel gets the current logging level for the logger with the
// provided name.
func GetLoggerLevel(loggerName string) string {
return strings.ToUpper(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)
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。