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