1 Star 0 Fork 2

who7708 / etcd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
debug.go 947 Bytes
一键复制 编辑 原始数据 按行查看 历史
package etcd
import (
"io/ioutil"
"log"
"strings"
)
type Logger interface {
Debug(args ...interface{})
Debugf(fmt string, args ...interface{})
Warning(args ...interface{})
Warningf(fmt string, args ...interface{})
}
var logger Logger
func SetLogger(log Logger) {
logger = log
}
func GetLogger() Logger {
return logger
}
type defaultLogger struct {
log *log.Logger
}
func (p *defaultLogger) Debug(args ...interface{}) {
p.log.Println(args)
}
func (p *defaultLogger) Debugf(fmt string, args ...interface{}) {
// Append newline if necessary
if !strings.HasSuffix(fmt, "\n") {
fmt = fmt + "\n"
}
p.log.Printf(fmt, args)
}
func (p *defaultLogger) Warning(args ...interface{}) {
p.Debug(args)
}
func (p *defaultLogger) Warningf(fmt string, args ...interface{}) {
p.Debugf(fmt, args)
}
func init() {
// Default logger uses the go default log.
SetLogger(&defaultLogger{log.New(ioutil.Discard, "go-etcd", log.LstdFlags)})
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/who7708/etcd.git
git@gitee.com:who7708/etcd.git
who7708
etcd
etcd
v0.4.6

搜索帮助

344bd9b3 5694891 D2dac590 5694891