You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can specify a custom logger when opening a database:
cfg, _:=mysql.ParseDSN(dsName)
// set a custom loggertracer:=log.New(os.Stdout, "[mysql] ", log.Ldate|log.Ltime|log.Lshortfile)
cfg.Logger=tracerconnector, err:=mysql.NewConnector(cfg)
iferr!=nil {
returnerr
}
db:=sql.OpenDB(connector)
But the logger won't log SQL statements from Exec() and Query(), but only some internal problems. See mysqlConn.log() usage.
Is it possible to add an sql logging in the driver? This may be a flag in a config like cfg.LogStatements = true or a separate logger/tracer field cfg.Tracer like this implemented in the PGX driver tracelog:
Activity
feat: add QueryTracer interface for SQL statement tracing (go-sql-dri…
feat: add QueryTracer interface for SQL statement tracing (go-sql-dri…
feat: add QueryTracer interface for SQL statement tracing (go-sql-dri…
# feat: add QueryTracer interface for SQL statement tracing (go-sql-d…