Documentation ¶
Overview ¶
Package sqllog provides a logging hook for go-mssqldb that turns mssqldb errors into proper logging using logrus. See README.md.
Index ¶
- func InstallMssql()
- func LoggerOrNil(ctx context.Context) mssql.ContextLogger
- func With(ctx context.Context, logger logrus.FieldLogger, dbi DB, ...) context.Context
- func WithLogger(ctx context.Context, logger mssql.ContextLogger) context.Context
- type DB
- type LogrusLogger
- type LogrusMssqlLogger
- type QuerierExecer
- type Row
- type StandardFallbackLogrusMssqlLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InstallMssql ¶
func InstallMssql()
func LoggerOrNil ¶
func LoggerOrNil(ctx context.Context) mssql.ContextLogger
func With ¶
func With(ctx context.Context, logger logrus.FieldLogger, dbi DB, fallback ...LogrusMssqlLogger) context.Context
With configures a standard opinionated logger, see LogrusLogger.
func WithLogger ¶
WithLogger attaches an mssql.ContextLogger to ctx. This is the basic hook and you may use this directly to override the SQL logger per call.
Types ¶
type DB ¶
DB interface is used simply to avoid a potentially common mistake of passing a *Conn or *Tx to With()
type LogrusLogger ¶
type LogrusLogger struct { Logger logrus.FieldLogger // Normal logrus output Querier QuerierExecer // For ##log-table dumping, this is used to fetch table data Fallback LogrusMssqlLogger // If `<level>:` prefix is not present, forward to this logger Stderr io.Writer // The special "stderr:" level is written here }
LogrusLogger is an opinionated logger implementation that parses the SQL log string and turns it into a nice logrus log; see README.md for further description.
type LogrusMssqlLogger ¶
type QuerierExecer ¶
type StandardFallbackLogrusMssqlLogger ¶
StandardFallbackLogrusMssqlLogger defines the behaviour if no log level is specified with the "level:" prefix; i.e. messages that are likely not logged with this framework in mind.
func (StandardFallbackLogrusMssqlLogger) Log ¶
func (s StandardFallbackLogrusMssqlLogger) Log(ctx context.Context, logger logrus.FieldLogger, category msdsn.Log, msg string)