forked from free-lancers/electricity_bill_calc_service
		
	enhance(db):加入调试模式的SQL输出。
This commit is contained in:
		| @@ -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 | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user