You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
762 B
34 lines
762 B
package internal
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
|
"gorm.io/gorm/logger"
|
|
)
|
|
|
|
type writer struct {
|
|
logger.Writer
|
|
}
|
|
|
|
// NewWriter writer 构造函数
|
|
// Author [SliverHorn](https://github.com/SliverHorn)
|
|
func NewWriter(w logger.Writer) *writer {
|
|
return &writer{Writer: w}
|
|
}
|
|
|
|
// Printf 格式化打印日志
|
|
// Author [SliverHorn](https://github.com/SliverHorn)
|
|
func (w *writer) Printf(message string, data ...interface{}) {
|
|
var logZap bool
|
|
switch global.GVA_CONFIG.System.DbType {
|
|
case "mysql":
|
|
logZap = global.GVA_CONFIG.Mysql.LogZap
|
|
case "pgsql":
|
|
logZap = global.GVA_CONFIG.Pgsql.LogZap
|
|
}
|
|
if logZap {
|
|
global.GVA_LOG.Info(fmt.Sprintf(message+"\n", data...))
|
|
} else {
|
|
w.Writer.Printf(message, data...)
|
|
}
|
|
}
|