Files
dbx/dbxp/pxg.go
Elijah Duffy 14686a83cb move utilities out of db-specific packages
DestName & NormalCols now live in root dbx package utilizing union
interfaces. SoftDelete helper has been dropped.
2026-01-28 11:57:50 -08:00

37 lines
839 B
Go

package dbxp
import (
"context"
"fmt"
"strings"
"gitea.auvem.com/go-toolkit/dbx"
"gitea.auvem.com/go-toolkit/dbx/internal/dbxshared"
"github.com/fatih/color"
"github.com/go-jet/jet/v2/postgres"
)
func init() {
dbxshared.RegisterLogger(dbx.DialectPostgres, &_postgresLogger{})
}
type _postgresLogger struct{}
func (_postgresLogger) InitLogger() {
postgres.SetQueryLogger(func(ctx context.Context, queryInfo postgres.QueryInfo) {
_, args := queryInfo.Statement.Sql()
dbxshared.DBModule.Logger().Debug(
"Executed SQL query",
"args", args,
"duration", queryInfo.Duration,
"rows", queryInfo.RowsProcessed,
"err", queryInfo.Err,
)
lines := strings.Split(queryInfo.Statement.DebugSql(), "\n")
for i, line := range lines {
fmt.Printf("%s\t%s\n", color.CyanString(fmt.Sprintf("%03d", i)), line)
}
})
}