Documentation
¶
Overview ¶
Package sqlogger provides a custom slog.Handler that logs to a SQLite database and standard output.
Index ¶
- func Err(err error) slog.Attr
- func FiberRequestLogger(c *fiber.Ctx) error
- type ByteRenderer
- type LogRecord
- type Options
- type SQLogHandler
- func (h *SQLogHandler) Close()
- func (h *SQLogHandler) Enabled(ctx context.Context, level slog.Level) bool
- func (h *SQLogHandler) Handle(c context.Context, r slog.Record) error
- func (h *SQLogHandler) Level() *slog.LevelVar
- func (h *SQLogHandler) Name() string
- func (h *SQLogHandler) Retrieve(numEntries int) ([]LogRecord, error)
- func (h *SQLogHandler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *SQLogHandler) WithGroup(name string) slog.Handler
- type SQLogHandlerInterface
- type StringRenderer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FiberRequestLogger ¶
FiberRequestLogger logs HTTP requests on entry and exit
Types ¶
type ByteRenderer ¶
func (*ByteRenderer) CloneBytes ¶
func (r *ByteRenderer) CloneBytes() []byte
CloneBytes returns a copy of the buffer contents, so the returned copy is owned by the caller
func (*ByteRenderer) Render ¶
func (r *ByteRenderer) Render(inputs ...any)
func (*ByteRenderer) Renderln ¶
func (r *ByteRenderer) Renderln(inputs ...any)
type Options ¶
type Options struct {
// Level reports the minimum level to log.
// Levels with lower levels are discarded.
// If nil, the Handler uses [slog.LevelInfo].
Level slog.Leveler
NoColor bool
// LogDir specifies the directory where log files will be stored.
// If empty, the current working directory is used.
LogDir string
}
type SQLogHandler ¶
type SQLogHandler struct {
// contains filtered or unexported fields
}
func NewSQLogHandler ¶
func NewSQLogHandler(opts *Options) (*SQLogHandler, error)
func (*SQLogHandler) Close ¶
func (h *SQLogHandler) Close()
func (*SQLogHandler) Level ¶
func (h *SQLogHandler) Level() *slog.LevelVar
func (*SQLogHandler) Name ¶
func (h *SQLogHandler) Name() string
func (*SQLogHandler) Retrieve ¶
func (h *SQLogHandler) Retrieve(numEntries int) ([]LogRecord, error)
Retrieve returns up to numEntries most recent LogRecord entries from the log handler. If there are fewer than numEntries available, all available entries are returned. Returns a slice of LogRecord and an error if retrieval fails.
type SQLogHandlerInterface ¶
type StringRenderer ¶
func (*StringRenderer) Render ¶
func (r *StringRenderer) Render(inputs ...any)
func (*StringRenderer) RenderWithSeparator ¶
func (r *StringRenderer) RenderWithSeparator(separator string, inputs ...any)
func (*StringRenderer) Renderln ¶
func (r *StringRenderer) Renderln(inputs ...any)
Click to show internal directories.
Click to hide internal directories.