enhance(db):加入调试模式的SQL输出。
This commit is contained in:
parent
b2812b3e6d
commit
ff9df8f99c
|
@ -2,6 +2,7 @@ package global
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"electricity_bill_calc/config"
|
||||
|
@ -9,6 +10,7 @@ import (
|
|||
// _ "github.com/lib/pq"
|
||||
_ "github.com/jackc/pgx/v5/stdlib"
|
||||
"xorm.io/xorm"
|
||||
"xorm.io/xorm/log"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -44,5 +46,10 @@ func SetupDatabaseConnection() error {
|
|||
DBConn.SetMaxOpenConns(config.DatabaseSettings.MaxOpenConns)
|
||||
DBConn.SetConnMaxLifetime(60 * time.Second)
|
||||
|
||||
if strings.ToLower(config.ServerSettings.RunMode) == "debug" {
|
||||
DBConn.ShowSQL(true)
|
||||
DBConn.Logger().SetLevel(log.LOG_DEBUG)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user