Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextLoggerBuilder ¶ added in v1.6.0
ContextLoggerBuilder produces a Logger bound to a request context.
type Hook ¶
type Hook struct {
*Options
}
Hook is an otsql.Hook that emits an access log entry after every SQL event.
type Level ¶ added in v1.6.0
type Level int
Level is the log level used to dispatch a log entry to one of the Logger methods.
const ( LevelDebug Level = iota LevelInfo LevelError // LevelOff drops the entry instead of logging it. Set it per method with // WithMethodLevel to silence a routine method such as ping. A failed or // slow event is still logged, because those branches pick their level // before the method override is read. // // WithDefaultLevel(LevelOff) on its own silences nothing: DefaultLevel is // consulted only for a method missing from MethodLevels, and newOptions // gives every otsql.Method an entry. Silence each method you want dropped. LevelOff )
type Logger ¶
type Logger interface {
Debug(message string, args ...any)
Info(message string, args ...any)
Error(message string, args ...any)
WithFields(fields ...any) Logger
}
Logger is the minimal logging interface required by the hook. It is intentionally implementation-agnostic: args are flat key/value tuples (k1, v1, k2, v2, ...).
type Option ¶
type Option func(*Options)
Option configures a Hook.
func WithDefaultLevel ¶
func WithLogger ¶
func WithLogger(builder ContextLoggerBuilder) Option
WithLogger installs a ContextLoggerBuilder together with the default level to use when a method has no explicit override. Both arguments are required: it is impossible to install a logger without choosing a default level.