I couldn't find it documentation how to log sql queries if I use pgx pool. For example I have created pool like this:
func DB() *pgxpool.Pool {
connStr := os.Getenv("DATABASE_URL")
conn, err := pgxpool.Connect(context.Background(), connStr)
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to connect to database: %v\n", err)
os.Exit(1)
}
return conn
}
Please tell me how to log my queries then?
I ended up with the following solution: