1 Star 0 Fork 1

周涛 / go_utils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gormLoger.go 851 Bytes
一键复制 编辑 原始数据 按行查看 历史
周涛 提交于 2020-09-03 17:44 . 更新gormV1使用的SLSLogger
package aliSLS
import (
"fmt"
"strconv"
)
type gormSLSLogger struct {
agent SLSAgent
}
func (sls *gormSLSLogger) GormSuccessCallback(sql string, source string, rows int, duration float64) {
_ = sls.agent.SendCustomizeMap(map[string]string{
"sql": sql,
"file": source,
"rows": strconv.Itoa(rows),
"duration": fmt.Sprintf("%.2f", duration),
"type": "sql",
})
}
func (sls *gormSLSLogger) GormFailCallback(source string, msg ...interface{}) {
_ = sls.agent.SendCustomizeMap(map[string]string{
"file": source,
"msg": fmt.Sprintf("%v", msg),
"type": "sql",
})
}
func NewGormSLSLogger(agent SLSAgent) GormSLSLogger {
return &gormSLSLogger{agent}
}
type GormSLSLogger interface {
GormSuccessCallback(sql string, source string, rows int, duration float64)
GormFailCallback(source string, msg ...interface{})
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/super_step/go_utils.git
git@gitee.com:super_step/go_utils.git
super_step
go_utils
go_utils
v1.1.0

搜索帮助

344bd9b3 5694891 D2dac590 5694891