Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*QueryHook)
Option is a function that configures a QueryHook.
func WithErrorQueryLogLevel ¶
WithErrorQueryLogLevel sets the log level for queries that result in an error.
func WithLogFormat ¶
func WithLogFormat(f logFormat) Option
WithLogFormat sets the custom format for slog output.
func WithLogger ¶
WithLogger sets the *slog.Logger instance.
func WithQueryLogLevel ¶
WithQueryLogLevel sets the log level for general queries.
func WithSlowQueryLogLevel ¶
WithSlowQueryLogLevel sets the log level for slow queries.
func WithSlowQueryThreshold ¶
WithSlowQueryThreshold sets the duration threshold for identifying slow queries.
type QueryHook ¶
type QueryHook struct {
// contains filtered or unexported fields
}
QueryHook is a hook for Bun that enables logging with slog. It implements bun.QueryHook interface.
func NewQueryHook ¶
NewQueryHook initializes a new QueryHook with the given options.
func (*QueryHook) AfterQuery ¶
func (h *QueryHook) AfterQuery(ctx context.Context, event *bun.QueryEvent)
AfterQuery is called after a query is executed. It logs the query based on its duration and whether it resulted in an error.
func (*QueryHook) BeforeQuery ¶
BeforeQuery is called before a query is executed.