log

package
v0.1.6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(level, format string) *slog.Logger

New builds a slog.Logger whose handler writes to os.Stderr via a SwappableWriter. The default constructor is preserved for callers that don't need the swap surface.

Types

type SwappableWriter added in v0.1.5

type SwappableWriter struct {
	// contains filtered or unexported fields
}

SwappableWriter is an io.Writer that can be redirected to a different target at runtime without re-wiring the slog handler. The daemon installs one as the slog sink at startup; the launcher redirects it to a tempfile while the in-process TUI owns the terminal, then restores it on exit so headless mode keeps stderr.

func NewSwappableWriter added in v0.1.5

func NewSwappableWriter(w io.Writer) *SwappableWriter

NewSwappableWriter returns a SwappableWriter pointed at w.

func NewWithSwap added in v0.1.5

func NewWithSwap(level, format string) (*slog.Logger, *SwappableWriter)

NewWithSwap is the variant used by main: it returns both the slog Logger and the SwappableWriter behind its handler, so the launcher can redirect stderr while the TUI runs.

func (*SwappableWriter) Redirect added in v0.1.5

func (s *SwappableWriter) Redirect(w io.Writer)

Redirect replaces the active target. The previous target is remembered so Restore can reinstate it.

func (*SwappableWriter) Restore added in v0.1.5

func (s *SwappableWriter) Restore()

Restore reverts to the writer that was active before the most recent Redirect. No-op when nothing was saved.

func (*SwappableWriter) Write added in v0.1.5

func (s *SwappableWriter) Write(p []byte) (int, error)

Write delegates to the active target. Holds the mutex briefly so concurrent log lines never interleave with a redirect transition.

Jump to

Keyboard shortcuts

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