diaglog

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: AGPL-3.0 Imports: 16 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 diaglog provides bounded, non-blocking JSONL diagnostic recording shared by the desktop host and CLI with a single dropped-record counter.

Index

Constants

View Source
const (
	DefaultQueueCapacity = 1024
)

Variables

View Source
var (
	ErrInvalidTarget             = errors.New("trace target is invalid")
	ErrInvalidConfig             = errors.New("trace configuration is invalid")
	ErrRunIDUnavailable          = errors.New("trace run identity is unavailable")
	ErrTraceDirectoryUnavailable = errors.New("trace directory is unavailable")
	ErrTraceFileUnavailable      = errors.New("trace file is unavailable")
	ErrTraceNameUnavailable      = errors.New("trace filename is unavailable")
	ErrTraceExists               = errors.New("trace path already exists")
)

Functions

This section is empty.

Types

type Recorder

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

Recorder writes bounded asynchronous JSONL diagnostic records off transfer goroutines, tracking all queue/encode/upstream loss with one dropped counter.

func Disabled

func Disabled(session string, err error) *Recorder

Disabled retains a startup failure without making diagnostics an admission dependency. No queue or writer goroutine is started.

func OpenRotating

func OpenRotating(directory, session string) (*Recorder, error)

OpenRotating creates a rotating host support log (`host-*.jsonl`) bounded in both per-file size and retained file count.

func OpenRun

func OpenRun(target Target, command string, opts RunOptions) (*Recorder, error)

OpenRun creates a single owner-only NDJSON trace file for one CLI invocation.

func (*Recorder) AddDropped

func (r *Recorder) AddDropped(count uint64)

AddDropped merges upstream non-blocking buffer drops into the single dropped counter.

func (*Recorder) Close

func (r *Recorder) Close() error

Close flushes and joins a rotating host recorder.

func (*Recorder) CloseRun

func (r *Recorder) CloseRun() RunStatus

CloseRun flushes, writes the terminal summary, syncs once, and returns final counts.

func (*Recorder) Path

func (r *Recorder) Path() string

func (*Recorder) Record

func (r *Recorder) Record(event string, fields any)

Record enqueues a structured host event in rotating mode.

func (*Recorder) RecordRun

func (r *Recorder) RecordRun(entry RunRecord) bool

RecordRun enqueues one timestamped, sequenced event in CLI run mode without performing file IO on the caller's goroutine.

func (*Recorder) RunID

func (r *Recorder) RunID() string

type RunOptions

type RunOptions struct {
	QueueCapacity int
	Now           func() time.Time
	Random        io.Reader
}

type RunRecord

type RunRecord struct {
	Level       string
	Event       string
	Scope       *diagnostics.Scope
	SourceTime  time.Time
	Correlation any
	Payload     any
}

type RunStatus

type RunStatus struct {
	EventsWritten uint64
	Dropped       uint64
	WriterFailed  bool
}

func (RunStatus) Complete

func (status RunStatus) Complete() bool

type Target

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

Target couples the no-clobber policy to the file or directory namespace selected by the caller.

func ExactFile

func ExactFile(path string) (Target, error)

ExactFile claims a single new file path so collisions preserve prior evidence.

func RunDirectory

func RunDirectory(directory string) (Target, error)

RunDirectory generates a unique file per invocation inside directory.

Jump to

Keyboard shortcuts

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