|
@@ -4,6 +4,7 @@ import (
|
|
"context"
|
|
"context"
|
|
"database/sql"
|
|
"database/sql"
|
|
"fmt"
|
|
"fmt"
|
|
|
|
+ "os"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
"github.com/pkg/errors"
|
|
"github.com/pkg/errors"
|
|
@@ -27,7 +28,7 @@ func (db *DBMethods) Begin(ctx context.Context, opts *sql.TxOptions) (*Tx, error
|
|
if db.Debug {
|
|
if db.Debug {
|
|
t := time.Now()
|
|
t := time.Now()
|
|
tx, err := db.DB.BeginTx(ctx, opts)
|
|
tx, err := db.DB.BeginTx(ctx, opts)
|
|
- log("[func Begin]", t, err, true, "")
|
|
|
|
|
|
+ log(os.Stdout, "[func Begin]", t, err, true, "")
|
|
return &Tx{tx, db.Debug, db.Driver, t}, err
|
|
return &Tx{tx, db.Debug, db.Driver, t}, err
|
|
}
|
|
}
|
|
|
|
|
|
@@ -42,7 +43,7 @@ func (db *DBMethods) Close() error {
|
|
if db.Debug {
|
|
if db.Debug {
|
|
t := time.Now()
|
|
t := time.Now()
|
|
err := db.DB.Close()
|
|
err := db.DB.Close()
|
|
- log("[func Close]", t, err, false, "")
|
|
|
|
|
|
+ log(os.Stdout, "[func Close]", t, err, false, "")
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
return db.DB.Close()
|
|
return db.DB.Close()
|
|
@@ -52,7 +53,7 @@ func (db *DBMethods) Exec(ctx context.Context, query string, args ...any) (sql.R
|
|
if db.Debug {
|
|
if db.Debug {
|
|
t := time.Now()
|
|
t := time.Now()
|
|
res, err := db.DB.ExecContext(ctx, db.fixQuery(query), args...)
|
|
res, err := db.DB.ExecContext(ctx, db.fixQuery(query), args...)
|
|
- log("[func Exec]", t, err, false, db.fixQuery(query), args...)
|
|
|
|
|
|
+ log(os.Stdout, "[func Exec]", t, err, false, db.fixQuery(query), args...)
|
|
return res, err
|
|
return res, err
|
|
}
|
|
}
|
|
return db.DB.ExecContext(ctx, db.fixQuery(query), args...)
|
|
return db.DB.ExecContext(ctx, db.fixQuery(query), args...)
|
|
@@ -62,7 +63,7 @@ func (db *DBMethods) Ping(ctx context.Context) error {
|
|
if db.Debug {
|
|
if db.Debug {
|
|
t := time.Now()
|
|
t := time.Now()
|
|
err := db.DB.PingContext(ctx)
|
|
err := db.DB.PingContext(ctx)
|
|
- log("[func Ping]", t, err, false, "")
|
|
|
|
|
|
+ log(os.Stdout, "[func Ping]", t, err, false, "")
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
return db.DB.PingContext(ctx)
|
|
return db.DB.PingContext(ctx)
|
|
@@ -72,7 +73,7 @@ func (db *DBMethods) Prepare(ctx context.Context, query string) (*sql.Stmt, erro
|
|
if db.Debug {
|
|
if db.Debug {
|
|
t := time.Now()
|
|
t := time.Now()
|
|
stm, err := db.DB.PrepareContext(ctx, db.fixQuery(query))
|
|
stm, err := db.DB.PrepareContext(ctx, db.fixQuery(query))
|
|
- log("[func Prepare]", t, err, false, db.fixQuery(query))
|
|
|
|
|
|
+ log(os.Stdout, "[func Prepare]", t, err, false, db.fixQuery(query))
|
|
return stm, err
|
|
return stm, err
|
|
}
|
|
}
|
|
return db.DB.PrepareContext(ctx, db.fixQuery(query))
|
|
return db.DB.PrepareContext(ctx, db.fixQuery(query))
|
|
@@ -82,7 +83,7 @@ func (db *DBMethods) Query(ctx context.Context, query string, args ...any) (*sql
|
|
if db.Debug {
|
|
if db.Debug {
|
|
t := time.Now()
|
|
t := time.Now()
|
|
rows, err := db.DB.QueryContext(ctx, db.fixQuery(query), args...)
|
|
rows, err := db.DB.QueryContext(ctx, db.fixQuery(query), args...)
|
|
- log("[func Query]", t, err, false, db.fixQuery(query), args...)
|
|
|
|
|
|
+ log(os.Stdout, "[func Query]", t, err, false, db.fixQuery(query), args...)
|
|
return rows, err
|
|
return rows, err
|
|
}
|
|
}
|
|
return db.DB.QueryContext(ctx, db.fixQuery(query), args...)
|
|
return db.DB.QueryContext(ctx, db.fixQuery(query), args...)
|
|
@@ -92,7 +93,7 @@ func (db *DBMethods) QueryRow(ctx context.Context, query string, args ...any) *s
|
|
if db.Debug {
|
|
if db.Debug {
|
|
t := time.Now()
|
|
t := time.Now()
|
|
row := db.DB.QueryRowContext(ctx, db.fixQuery(query), args...)
|
|
row := db.DB.QueryRowContext(ctx, db.fixQuery(query), args...)
|
|
- log("[func QueryRow]", t, nil, false, db.fixQuery(query), args...)
|
|
|
|
|
|
+ log(os.Stdout, "[func QueryRow]", t, nil, false, db.fixQuery(query), args...)
|
|
return row
|
|
return row
|
|
}
|
|
}
|
|
return db.DB.QueryRowContext(ctx, db.fixQuery(query), args...)
|
|
return db.DB.QueryRowContext(ctx, db.fixQuery(query), args...)
|