加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
logger.go 1.15 KB
一键复制 编辑 原始数据 按行查看 历史
package ping
import "log"
type Logger interface {
Fatalf(format string, v ...interface{})
Errorf(format string, v ...interface{})
Warnf(format string, v ...interface{})
Infof(format string, v ...interface{})
Debugf(format string, v ...interface{})
}
type StdLogger struct {
Logger *log.Logger
}
func (l StdLogger) Fatalf(format string, v ...interface{}) {
l.Logger.Printf("FATAL: "+format, v...)
}
func (l StdLogger) Errorf(format string, v ...interface{}) {
l.Logger.Printf("ERROR: "+format, v...)
}
func (l StdLogger) Warnf(format string, v ...interface{}) {
l.Logger.Printf("WARN: "+format, v...)
}
func (l StdLogger) Infof(format string, v ...interface{}) {
l.Logger.Printf("INFO: "+format, v...)
}
func (l StdLogger) Debugf(format string, v ...interface{}) {
l.Logger.Printf("DEBUG: "+format, v...)
}
type NoopLogger struct {
}
func (l NoopLogger) Fatalf(format string, v ...interface{}) {
}
func (l NoopLogger) Errorf(format string, v ...interface{}) {
}
func (l NoopLogger) Warnf(format string, v ...interface{}) {
}
func (l NoopLogger) Infof(format string, v ...interface{}) {
}
func (l NoopLogger) Debugf(format string, v ...interface{}) {
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化