From b59cef44ca725099a624290d8d9d5d1c5db48128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Mon, 31 Mar 2025 18:18:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9F=BA=E7=A1=80=E5=85=AC?= =?UTF-8?q?=E5=85=B1logRecord=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- httpclient/log.go | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/httpclient/log.go b/httpclient/log.go index 42cbf02..755e7e0 100644 --- a/httpclient/log.go +++ b/httpclient/log.go @@ -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...) + } + +}