qblogz

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2022 License: AGPL-3.0 Imports: 7 Imported by: 0

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

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	sqlmw.NullInterceptor
	Log   *qblog.Logger
	Level qblog.Level
}

func (Logger) ConnBeginTx

func (l Logger) ConnBeginTx(
	ctx context.Context,
	conn driver.ConnBeginTx,
	opts driver.TxOptions,
) (context.Context, driver.Tx, error)

func (Logger) ConnExecContext

func (l Logger) ConnExecContext(
	ctx context.Context,
	conn driver.ExecerContext,
	query string,
	args []driver.NamedValue,
) (driver.Result, error)

func (Logger) ConnQueryContext

func (l Logger) ConnQueryContext(
	ctx context.Context,
	conn driver.QueryerContext,
	query string,
	args []driver.NamedValue,
) (context.Context, driver.Rows, error)

func (Logger) StmtExecContext

func (l Logger) StmtExecContext(
	ctx context.Context,
	conn driver.StmtExecContext,
	query string,
	args []driver.NamedValue,
) (driver.Result, error)

func (Logger) StmtQueryContext

func (l Logger) StmtQueryContext(
	ctx context.Context,
	conn driver.StmtQueryContext,
	query string,
	args []driver.NamedValue,
) (context.Context, driver.Rows, error)

func (Logger) TxCommit

func (l Logger) TxCommit(ctx context.Context, tx driver.Tx) error

func (Logger) TxRollback

func (l Logger) TxRollback(ctx context.Context, tx driver.Tx) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL