增加基础公共logRecord方法
This commit is contained in:
parent
6a5aefafae
commit
b59cef44ca
@ -7,7 +7,10 @@
|
||||
// Date : 2025-03-31 18:02
|
||||
package httpclient
|
||||
|
||||
import "go.uber.org/zap"
|
||||
import (
|
||||
"git.zhangdeman.cn/zhangdeman/consts"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
var (
|
||||
logger *zap.Logger
|
||||
@ -21,3 +24,28 @@ var (
|
||||
func SetLogger(l *zap.Logger) {
|
||||
logger = l
|
||||
}
|
||||
|
||||
// logRecord 日志记录
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:07 2025/3/31
|
||||
func logRecord(logInstance *zap.Logger, level consts.LogLevel, msg string, fields ...zap.Field) {
|
||||
if nil == logInstance {
|
||||
// 未设置日志实例
|
||||
return
|
||||
}
|
||||
switch level {
|
||||
case consts.LogLevelDebug:
|
||||
logInstance.Debug(msg, fields...)
|
||||
case consts.LogLevelInfo:
|
||||
logInstance.Info(msg, fields...)
|
||||
case consts.LogLevelWarn:
|
||||
logInstance.Warn(msg, fields...)
|
||||
case consts.LogLevelError:
|
||||
logInstance.Error(msg, fields...)
|
||||
case consts.LogLevelPanic:
|
||||
logInstance.Panic(msg, fields...)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user