1 Star 0 Fork 0

天雨流芳 / go-micro-framework

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
otelzap_log.go 3.19 KB
一键复制 编辑 原始数据 按行查看 历史
天雨流芳 提交于 2024-03-14 19:42 . 日志模块
package logger
import (
"context"
"fmt"
"go.uber.org/zap"
)
func (l *ZapLogger) Debug(msg string) {
if l.withSugar {
l.sugarLogger.Debug(msg)
} else {
l.Logger.Debug(msg)
}
}
func (l *ZapLogger) DebugF(format string, v ...interface{}) {
if l.withSugar {
l.sugarLogger.Debugf(format, v...)
} else {
msg := fmt.Sprintf(format, v...)
l.Logger.Debug(msg)
}
}
func (l *ZapLogger) DebugContext(ctx context.Context, msg string) {
fields := l.logFields(ctx, zap.DebugLevel, msg)
if l.withSugar {
l.sugarLogger.Debug(msg, fields)
} else {
l.Logger.Debug(msg, fields...)
}
}
func (l *ZapLogger) DebugContextF(ctx context.Context, format string, v ...interface{}) {
msg := fmt.Sprintf(format, v...)
fields := l.logFields(ctx, zap.DebugLevel, msg)
if l.withSugar {
l.sugarLogger.Debug(msg, fields)
} else {
l.Logger.Debug(msg, fields...)
}
}
func (l *ZapLogger) Info(msg string) {
if l.withSugar {
l.sugarLogger.Info(msg)
} else {
l.Logger.Info(msg)
}
}
func (l *ZapLogger) InfoF(format string, v ...interface{}) {
if l.withSugar {
l.sugarLogger.Infof(format, v...)
} else {
msg := fmt.Sprintf(format, v...)
l.Logger.Info(msg)
}
}
func (l *ZapLogger) InfoContext(ctx context.Context, msg string) {
fields := l.logFields(ctx, zap.DebugLevel, msg)
if l.withSugar {
l.sugarLogger.Info(msg, fields)
} else {
l.Logger.Info(msg, fields...)
}
}
func (l *ZapLogger) InfoContextF(ctx context.Context, format string, v ...interface{}) {
msg := fmt.Sprintf(format, v...)
fields := l.logFields(ctx, zap.DebugLevel, msg)
if l.withSugar {
l.sugarLogger.Info(msg, fields)
} else {
l.Logger.Info(msg, fields...)
}
}
func (l *ZapLogger) Warn(msg string) {
if l.withSugar {
l.sugarLogger.Warn(msg)
} else {
l.Logger.Warn(msg)
}
}
func (l *ZapLogger) WarnF(format string, v ...interface{}) {
if l.withSugar {
l.sugarLogger.Warnf(format, v...)
} else {
msg := fmt.Sprintf(format, v...)
l.Logger.Warn(msg)
}
}
func (l *ZapLogger) WarnContext(ctx context.Context, msg string) {
fields := l.logFields(ctx, zap.DebugLevel, msg)
if l.withSugar {
l.sugarLogger.Warn(msg, fields)
} else {
l.Logger.Warn(msg, fields...)
}
}
func (l *ZapLogger) WarnContextF(ctx context.Context, format string, v ...interface{}) {
msg := fmt.Sprintf(format, v...)
fields := l.logFields(ctx, zap.DebugLevel, msg)
if l.withSugar {
l.sugarLogger.Warn(msg, fields)
} else {
l.Logger.Warn(msg, fields...)
}
}
func (l *ZapLogger) Error(msg string) {
if l.withSugar {
l.sugarLogger.Error(msg)
} else {
l.Logger.Error(msg)
}
}
func (l *ZapLogger) ErrorF(format string, v ...interface{}) {
if l.withSugar {
l.sugarLogger.Errorf(format, v...)
} else {
msg := fmt.Sprintf(format, v...)
l.Logger.Error(msg)
}
}
func (l *ZapLogger) ErrorContext(ctx context.Context, msg string) {
fields := l.logFields(ctx, zap.DebugLevel, msg)
if l.withSugar {
l.sugarLogger.Error(msg, fields)
} else {
l.Logger.Error(msg, fields...)
}
}
func (l *ZapLogger) ErrorContextF(ctx context.Context, format string, v ...interface{}) {
msg := fmt.Sprintf(format, v...)
fields := l.logFields(ctx, zap.DebugLevel, msg)
if l.withSugar {
l.sugarLogger.Error(msg, fields)
} else {
l.Logger.Error(msg, fields...)
}
}
1
https://gitee.com/tylf2018/go-micro-framework.git
git@gitee.com:tylf2018/go-micro-framework.git
tylf2018
go-micro-framework
go-micro-framework
ad9b26ca148e

搜索帮助