logging

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 21 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 owns the process's rotating diagnostics. An entry point installs it once; a Node never installs a handler. Records contain identifiers and lifecycle metadata, never operation payloads.

Index

Constants

View Source
const (
	Begin       = "begin"
	Admitted    = "admitted"
	Completed   = "completed"
	Failed      = "failed"
	Cancelled   = "cancelled"
	Interrupted = "interrupted"
)

Phases of an observed operation.

View Source
const Target = "sailry"

Target is the message of every record this package owns. The handler writes those to the file and passes all others to the handler it replaced.

Variables

View Source
var ErrUnavailable = errors.New("logging is unavailable")

ErrUnavailable reports that logging could not be installed.

Functions

func CurrentFile

func CurrentFile() (string, error)

CurrentFile is the active file, or the latest earlier daily file before the first record. It is "" when there is none.

func Directory

func Directory() string

Directory is the profile's logs directory, "" before Install.

func Emit

func Emit(level slog.Level, attrs ...slog.Attr)

Emit writes one record. It does nothing before Install.

func Install

func Install(profile, application string) (func(), error)

Install starts the application's log under the profile at logs/<application>/current.log and makes it the slog default. application is "desktop" or "host". The returned function ends it after the Node has stopped. A second installation in one process fails.

func Retain

func Retain(profile string) error

Retain retires earlier daily files. A Node calls it only after it owns the profile, so a rejected second start cannot retire a running process's file. Other files, directories and links in the directory remain untouched.

func SetReport

func SetReport(receive func(slog.Level, Fields))

SetReport names the receiver of warning and error records, nil for none. It is called on the logging goroutine and must not block.

func Tail

func Tail(path string) ([]byte, error)

Tail is the diagnostics attachment: the last records of the active file's final mebibyte, each reduced by Remote, one JSON object per line. An empty path gives an empty attachment.

Types

type Fields

type Fields map[string]any

Fields are a record's allowlisted values: strings, int64, uint64 and bool.

func Remote

func Remote(values Fields) Fields

Remote is the part of a record that may leave the process: public tokens and counters, a valid application version, and a package only as "third_party". Configuration reasons and command stages use closed lists. Identifiers, names, details and paths never pass.

type Span

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

Span observes one operation. It never cancels or replays the work it describes.

func NewBackground

func NewBackground(area string, attrs ...slog.Attr) *Span

NewBackground observes a package's read at debug level.

func NewQuery

func NewQuery(area string, attrs ...slog.Attr) *Span

NewQuery observes an ordinary read: only a slow completion, a failure or an uncertain outcome is recorded.

func NewSpan

func NewSpan(area string, attrs ...slog.Attr) *Span

NewSpan records the operation's beginning.

func (*Span) Finish

func (span *Span) Finish(phase, code string, warn bool)

Finish records the outcome once. code is "" for success; warn lowers an expected failure to a warning.

func (*Span) Record

func (span *Span) Record(phase string)

Record notes an intermediate phase with the time since the beginning.

func (*Span) Set

func (span *Span) Set(attr slog.Attr)

Set adds or replaces a field.

Jump to

Keyboard shortcuts

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