Documentation ¶
Overview ¶
Package qblogz provides a sqlmw driver interceptor that logs to a qblog Logger (see http://github.com/ngrok/sqlmw).
Example ¶
// Log goes to os.Stderr, not os.Stdout. It has time info, i.e. we don't // want it in 'Output:'. Otherwise one would see something like: // // Oct 03 16:55:31.990 INFO [example] `conn:1` `exec…:CREATE TABLE example (id integer PRIMARY KEY, name text NOT NULL)` with `args:[]` // Oct 03 16:55:31.990 INFO [example] `conn:1` `…exec:91.529µs` with `err:<nil>` log := qblog.New("example") sql.Register("log/sqlite3", sqlmw.Driver( &sqlite3.SQLiteDriver{}, Logger{Log: log, Level: c4hgol.Info}, )) db, _ := sql.Open("log/sqlite3", ":memory:") defer db.Close() _, err := db.Exec(`CREATE TABLE example (id integer PRIMARY KEY, name text NOT NULL)`) fmt.Println(err)
Output: <nil>
Index ¶
- type Logger
- func (l Logger) ConnBeginTx(ctx context.Context, conn driver.ConnBeginTx, opts driver.TxOptions) (context.Context, driver.Tx, error)
- func (l Logger) ConnExecContext(ctx context.Context, conn driver.ExecerContext, query string, ...) (driver.Result, error)
- func (l Logger) ConnQueryContext(ctx context.Context, conn driver.QueryerContext, query string, ...) (context.Context, driver.Rows, error)
- func (l Logger) StmtExecContext(ctx context.Context, conn driver.StmtExecContext, query string, ...) (driver.Result, error)
- func (l Logger) StmtQueryContext(ctx context.Context, conn driver.StmtQueryContext, query string, ...) (context.Context, driver.Rows, error)
- func (l Logger) TxCommit(ctx context.Context, tx driver.Tx) error
- func (l Logger) TxRollback(ctx context.Context, tx driver.Tx) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.