log

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package log provides a colored, human-readable slog.Handler tuned for liteorm's statement logs: one line per executed statement with timing, the SQL, its bind arguments, the rows affected, and the Go source location that issued it — so you can watch every query during development and trace it back to the line of code. Wire it in with liteorm.WithLogger(log.New(os.Stderr, nil)). It also renders ordinary (non-statement) slog records as a plain line, so it can serve as a development logger for the whole program.

For structured/production logging use a standard slog handler instead (slog.NewJSONHandler / slog.NewTextHandler) — liteorm logs the same statement events through whichever handler is configured.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(w io.Writer, opts *Options) *slog.Logger

New returns an *slog.Logger backed by the colored statement handler.

func NewHandler

func NewHandler(w io.Writer, opts *Options) slog.Handler

NewHandler returns the colored statement handler writing to w.

Types

type Options

type Options struct {
	Level         slog.Level    // minimum level (default slog.LevelDebug — statement logs are emitted at debug)
	Color         bool          // ANSI color (default true; forced off when the NO_COLOR env var is set)
	SlowThreshold time.Duration // statements at or over this are highlighted (default 200ms; 0 disables)
	AbsPath       bool          // print the absolute caller path; by default it is shown relative to the working directory
}

Options configures the handler. A nil *Options uses the defaults.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL