log

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT, MIT Imports: 5 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 log is the logging seam: the CLI wants progress on stdout, the API wants the same events captured per job and streamed to a browser, so the orchestrator writes to a Sink and each consumer passes its own.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	OnEvent func(Event)
	// contains filtered or unexported fields
}

Buffer keeps every event and notifies a callback. What the API uses: the job holds the buffer so a browser attaching late still gets the whole history, then live updates.

Owner: the job that created it. The mutex guards Events against the SSE reader that snapshots it while the job goroutine appends; OnEvent is called OUTSIDE the mutex (rule 14).

func NewBuffer

func NewBuffer(onEvent func(Event)) *Buffer

NewBuffer returns an empty buffer.

func (*Buffer) Emit

func (b *Buffer) Emit(level Level, message string)

Emit appends and notifies.

func (*Buffer) Events

func (b *Buffer) Events() []Event

Events is a copy of everything emitted so far — never nil.

type Console

type Console struct{}

Console writes to stdout (errors to stderr). What the CLI uses.

func (Console) Emit

func (Console) Emit(level Level, message string)

Emit prints.

type Event

type Event struct {
	// Seq is monotonic within a sink; useful for resuming an SSE stream.
	Seq     int64  `json:"seq"`
	At      int64  `json:"at"`
	Level   Level  `json:"level"`
	Message string `json:"message"`
}

Event is one log line. JSON shape matches the SSE frame the UI reads.

type Level

type Level string

Level is an event's severity.

const (
	Info  Level = "info"
	Step  Level = "step"
	Warn  Level = "warn"
	Error Level = "error"
)

type Null

type Null struct{}

Null discards everything. For tests that assert on results rather than output.

func (Null) Emit

func (Null) Emit(Level, string)

Emit does nothing.

type Sink

type Sink interface {
	Emit(level Level, message string)
}

Sink receives events.

type Writer

type Writer struct {
	Out io.Writer
	Err io.Writer
}

Writer is Console over explicit streams — what the CLI uses so a test can capture its output.

func (Writer) Emit

func (w Writer) Emit(level Level, message string)

Emit prints to Err for errors, Out otherwise.

Jump to

Keyboard shortcuts

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