✨ 新增支持Gorm日志
This commit is contained in:
parent
e74d0280be
commit
3f6003edd7
21
gorm.go
Normal file
21
gorm.go
Normal 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{}
|
||||
}
|
Loading…
Reference in New Issue
Block a user