revert InitModuleDB pattern, back to single ModuleDB func
This commit is contained in:
13
dbx.go
13
dbx.go
@@ -92,17 +92,8 @@ func SQLO() *sql.DB {
|
|||||||
return sqlDB
|
return sqlDB
|
||||||
}
|
}
|
||||||
|
|
||||||
// ModuleDB returns the existing database module, or panics if it has not
|
// ModuleDB returns the database module with the provided configuration.
|
||||||
// been initialized yet.
|
func ModuleDB(dialect Dialect, cfg *DBConfig, forceDebugLog bool) *app.Module {
|
||||||
func ModuleDB() *app.Module {
|
|
||||||
if dbxshared.DBModule == nil {
|
|
||||||
panic("ModuleDB not initialized yet")
|
|
||||||
}
|
|
||||||
return dbxshared.DBModule
|
|
||||||
}
|
|
||||||
|
|
||||||
// InitModuleDB returns the database module with the provided configuration.
|
|
||||||
func InitModuleDB(dialect Dialect, cfg *DBConfig, forceDebugLog bool) *app.Module {
|
|
||||||
if dbxshared.DBModule != nil {
|
if dbxshared.DBModule != nil {
|
||||||
panic("ModuleDB initialized multiple times")
|
panic("ModuleDB initialized multiple times")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ type _mysqlLogger struct{}
|
|||||||
func (_mysqlLogger) InitLogger() {
|
func (_mysqlLogger) InitLogger() {
|
||||||
mysql.SetQueryLogger(func(ctx context.Context, queryInfo mysql.QueryInfo) {
|
mysql.SetQueryLogger(func(ctx context.Context, queryInfo mysql.QueryInfo) {
|
||||||
_, args := queryInfo.Statement.Sql()
|
_, args := queryInfo.Statement.Sql()
|
||||||
dbx.ModuleDB().Logger().Debug(
|
dbxshared.DBModule.Logger().Debug(
|
||||||
"Executed SQL query",
|
"Executed SQL query",
|
||||||
"args", args,
|
"args", args,
|
||||||
"duration", queryInfo.Duration,
|
"duration", queryInfo.Duration,
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ type _postgresLogger struct{}
|
|||||||
func (_postgresLogger) InitLogger() {
|
func (_postgresLogger) InitLogger() {
|
||||||
postgres.SetQueryLogger(func(ctx context.Context, queryInfo postgres.QueryInfo) {
|
postgres.SetQueryLogger(func(ctx context.Context, queryInfo postgres.QueryInfo) {
|
||||||
_, args := queryInfo.Statement.Sql()
|
_, args := queryInfo.Statement.Sql()
|
||||||
dbx.ModuleDB().Logger().Debug(
|
dbxshared.DBModule.Logger().Debug(
|
||||||
"Executed SQL query",
|
"Executed SQL query",
|
||||||
"args", args,
|
"args", args,
|
||||||
"duration", queryInfo.Duration,
|
"duration", queryInfo.Duration,
|
||||||
|
|||||||
Reference in New Issue
Block a user