1 Star 0 Fork 0

h79/goutils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
logger.go 762 Bytes
一键复制 编辑 原始数据 按行查看 历史
huqiuyun 提交于 2024-01-07 12:07 . 注删配置
package redis
import (
"context"
"encoding/json"
"fmt"
"gitee.com/h79/goutils/common/result"
"gitee.com/h79/goutils/dao/config"
"go.uber.org/zap"
)
type Logger struct {
config.RedisLogger
}
func (l *Logger) Printf(ctx context.Context, format string, v ...interface{}) {
if l.LogLevel <= 0 {
return
}
zap.L().Info("Redis", zap.String("info", fmt.Sprintf(format, v...)))
}
func (l *Logger) handlerConfig(ctx context.Context, cmd int, configType, conf string) (any, error) {
switch cmd {
case 1:
var c = config.RedisLogger{}
var err = json.Unmarshal([]byte(conf), &c)
if err != nil {
return "", err
}
l.LogLevel = c.LogLevel
return "", nil
case 2: //获取
return config.RedisLogger{}, nil
}
return "", result.RErrNotSupport
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/h79/goutils.git
git@gitee.com:h79/goutils.git
h79
goutils
goutils
v1.20.85

搜索帮助

A270a887 8829481 3d7a4017 8829481