Documentation ¶
Index ¶
- func LoggingConnector(log SQLLogger, connector driver.Connector) driver.Connector
- type DefaultSQLLogger
- func (dl *DefaultSQLLogger) ConnBegin(connID, txID int64, opts driver.TxOptions)
- func (dl *DefaultSQLLogger) ConnClose(connID int64)
- func (dl *DefaultSQLLogger) ConnExec(connID int64, query string, args []driver.Value)
- func (dl *DefaultSQLLogger) ConnExecContext(connID int64, query string, args []driver.NamedValue)
- func (dl *DefaultSQLLogger) ConnPrepare(connID, stmtID int64, query string)
- func (dl *DefaultSQLLogger) ConnPrepareContext(connID int64, stmtID int64, query string)
- func (dl *DefaultSQLLogger) ConnQuery(connID, rowsID int64, query string, args []driver.Value)
- func (dl *DefaultSQLLogger) ConnQueryContext(connID int64, rowsID int64, query string, args []driver.NamedValue)
- func (dl *DefaultSQLLogger) Connect(connID int64)
- func (dl *DefaultSQLLogger) RowsClose(rowsID int64)
- func (dl *DefaultSQLLogger) StmtClose(stmtID int64)
- func (dl *DefaultSQLLogger) StmtExec(stmtID int64, query string, args []driver.Value)
- func (dl *DefaultSQLLogger) StmtExecContext(stmtID int64, query string, args []driver.NamedValue)
- func (dl *DefaultSQLLogger) StmtQuery(stmtID, rowsID int64, query string, args []driver.Value)
- func (dl *DefaultSQLLogger) StmtQueryContext(stmtID int64, rowsID int64, query string, args []driver.NamedValue)
- func (dl *DefaultSQLLogger) TxCommit(txID int64)
- func (dl *DefaultSQLLogger) TxRollback(txID int64)
- type SQLLogger
- type StdLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoggingConnector ¶
LoggingConnector wraps the given driver.Connector and invokes the given SQLLogger for queries and other SQL operations.
Note: Due to the amount of optional interfaces in the database/sql/driver package, there might be some features of the original driver that are not exposed on the returned driver.Connector.
Types ¶
type DefaultSQLLogger ¶ added in v0.2.0
type DefaultSQLLogger struct { // Enabled sets, whether Enabled bool LogConnect bool LogClose bool // contains filtered or unexported fields }
DefaultSQLLogger is an implementation of the Logger interface logging to a *log.Logger from the standard library
func NewDefaultSQLLogger ¶ added in v0.2.0
func NewDefaultSQLLogger(log StdLogger) *DefaultSQLLogger
NewDefaultSQLLogger creates a new default SQL logger with sensible defaults
A *log.Logger can be passed or any other implementation of the StdLogger interface.
func (*DefaultSQLLogger) ConnBegin ¶ added in v0.2.0
func (dl *DefaultSQLLogger) ConnBegin(connID, txID int64, opts driver.TxOptions)
ConnBegin satisfies Logger interface
func (*DefaultSQLLogger) ConnClose ¶ added in v0.2.0
func (dl *DefaultSQLLogger) ConnClose(connID int64)
ConnClose satisfies Logger interface
func (*DefaultSQLLogger) ConnExec ¶ added in v0.2.0
func (dl *DefaultSQLLogger) ConnExec(connID int64, query string, args []driver.Value)
ConnExec satisfies Logger interface
func (*DefaultSQLLogger) ConnExecContext ¶ added in v0.2.0
func (dl *DefaultSQLLogger) ConnExecContext(connID int64, query string, args []driver.NamedValue)
ConnExecContext satisfies Logger interface
func (*DefaultSQLLogger) ConnPrepare ¶ added in v0.2.0
func (dl *DefaultSQLLogger) ConnPrepare(connID, stmtID int64, query string)
ConnPrepare satisfies Logger interface
func (*DefaultSQLLogger) ConnPrepareContext ¶ added in v0.2.0
func (dl *DefaultSQLLogger) ConnPrepareContext(connID int64, stmtID int64, query string)
ConnPrepareContext satisfies Logger interface
func (*DefaultSQLLogger) ConnQuery ¶ added in v0.2.0
func (dl *DefaultSQLLogger) ConnQuery(connID, rowsID int64, query string, args []driver.Value)
ConnQuery satisfies Logger interface
func (*DefaultSQLLogger) ConnQueryContext ¶ added in v0.2.0
func (dl *DefaultSQLLogger) ConnQueryContext(connID int64, rowsID int64, query string, args []driver.NamedValue)
ConnQueryContext satisfies Logger interface
func (*DefaultSQLLogger) Connect ¶ added in v0.2.0
func (dl *DefaultSQLLogger) Connect(connID int64)
Connect satisfies Logger interface
func (*DefaultSQLLogger) RowsClose ¶ added in v0.2.0
func (dl *DefaultSQLLogger) RowsClose(rowsID int64)
RowsClose satisfies Logger interface
func (*DefaultSQLLogger) StmtClose ¶ added in v0.2.0
func (dl *DefaultSQLLogger) StmtClose(stmtID int64)
StmtClose satisfies Logger interface
func (*DefaultSQLLogger) StmtExec ¶ added in v0.2.0
func (dl *DefaultSQLLogger) StmtExec(stmtID int64, query string, args []driver.Value)
StmtExec satisfies Logger interface
func (*DefaultSQLLogger) StmtExecContext ¶ added in v0.2.0
func (dl *DefaultSQLLogger) StmtExecContext(stmtID int64, query string, args []driver.NamedValue)
StmtExecContext satisfies Logger interface
func (*DefaultSQLLogger) StmtQuery ¶ added in v0.2.0
func (dl *DefaultSQLLogger) StmtQuery(stmtID, rowsID int64, query string, args []driver.Value)
StmtQuery satisfies Logger interface
func (*DefaultSQLLogger) StmtQueryContext ¶ added in v0.2.0
func (dl *DefaultSQLLogger) StmtQueryContext(stmtID int64, rowsID int64, query string, args []driver.NamedValue)
StmtQueryContext satisfies Logger interface
func (*DefaultSQLLogger) TxCommit ¶ added in v0.2.0
func (dl *DefaultSQLLogger) TxCommit(txID int64)
TxCommit satisfies Logger interface
func (*DefaultSQLLogger) TxRollback ¶ added in v0.2.0
func (dl *DefaultSQLLogger) TxRollback(txID int64)
TxRollback satisfies Logger interface
type SQLLogger ¶ added in v0.2.0
type SQLLogger interface { // Called on DB connect with a generated connection id Connect(connID int64) // Called on a transaction begin on a connection with the connection id and a generated transaction id ConnBegin(connID, txID int64, opts driver.TxOptions) // Called on a prepare statement on a connection with the connection id and a generated statement id ConnPrepare(connID, stmtID int64, query string) // Called on a prepare statement with context on a connection with the connection id and a generated statement id ConnPrepareContext(connID int64, stmtID int64, query string) // Called on a query on a connection with the connection id and a generated rows id ConnQuery(connID, rowsID int64, query string, args []driver.Value) // Called on a query with context on a connection with the connection id and a generated rows id ConnQueryContext(connID int64, rowsID int64, query string, args []driver.NamedValue) // Called on an exec on a connection with the connection id ConnExec(connID int64, query string, args []driver.Value) // Called on an exec with context on a connection with the connection id ConnExecContext(connID int64, query string, args []driver.NamedValue) // Called on a close on a connection with the connection id ConnClose(connID int64) // Called on an exec on a statement with the statement id StmtExec(stmtID int64, query string, args []driver.Value) // Called on an exec with context on a statement with the statement id StmtExecContext(stmtID int64, query string, args []driver.NamedValue) // Called on a query on a statement with the statement id and generated rows id StmtQuery(stmtID int64, rowsID int64, query string, args []driver.Value) // Called on a query with context on a statement with the statement id and generated rows id StmtQueryContext(stmtID int64, rowsID int64, query string, args []driver.NamedValue) // Called on a close on a statement with the statement id StmtClose(stmtID int64) // Called on a close on rows with the rows id RowsClose(rowsID int64) // Called on a commit on a transaction with the transaction id TxCommit(txID int64) // Called on a rollback on a transaction with the transaction id TxRollback(txID int64) }
SQLLogger is the interface for a specialized SQL logger that is used to log SQL queries and operations in the LoggingConnector
With this interface, adapters can be implemented for any log framework. For the standard library log.Logger, a DefaultSQLLogger is provided as a default implementation.
All methods are only called if the original operation returned without an error.