logging

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package logging provides slog setup plus an in-memory ring buffer handler backing GET /api/v1/logs. Request content is never logged (SPEC §2.1); only operational events flow here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseLevel added in v0.8.0

func ParseLevel(level string) slog.Level

ParseLevel maps debug|info|warn|error to a slog level (info otherwise).

func SetLevel added in v0.8.0

func SetLevel(level string)

SetLevel changes the level of the logger built by New / NewTo, for every logger derived from it. A no-op before one was built.

Types

type Entry

type Entry struct {
	Time    time.Time `json:"time"`
	Level   string    `json:"level"`
	Message string    `json:"message"`
	Attrs   string    `json:"attrs,omitempty"`
}

Entry is one captured log record.

type Ring

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

Ring is a fixed-size record buffer. Safe for concurrent use.

func New

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

New builds the daemon logger: level/format from config, teed into a Ring.

func NewRing

func NewRing(n int) *Ring

NewRing allocates a buffer of n entries.

func NewTo added in v0.6.0

func NewTo(w io.Writer, level, format string) (*slog.Logger, *Ring)

NewTo is New with an explicit sink (a file alongside stderr for a service that has no console — see config.Log.File).

func (*Ring) Subscribe added in v0.3.0

func (r *Ring) Subscribe() (<-chan Entry, func())

Subscribe streams entries as they are logged; call the returned func to detach. Fetch history with Tail — the channel carries only new entries.

func (*Ring) Tail

func (r *Ring) Tail(n int) []Entry

Tail returns up to n most recent entries, oldest first.

Jump to

Keyboard shortcuts

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