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