新增支持Gorm日志

This commit is contained in:
李寻欢 2021-12-27 09:36:32 +08:00
parent e74d0280be
commit 3f6003edd7

21
gorm.go Normal file
View File

@ -0,0 +1,21 @@
package logger
import "strings"
// 基于Gorm的日志实现
type gormLogger struct{}
// 打印
func (gormLogger) Write(p []byte) (n int, err error) {
str := string(p)
// 去掉第一行
//str = strings.Split(str, "\n")[1]
str = strings.Join(strings.Split(str, "\n")[1:], " ")
Say.Debug(str)
return 0, nil
}
// NewGormLogger ...
func NewGormLogger() *gormLogger {
return &gormLogger{}
}