eventlog

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNamespace    = errorx.NewNamespace("eventlog")
	ErrInvalidEvent = ErrNamespace.NewType("invalid_event")
)

Functions

This section is empty.

Types

type Event

type Event struct {
	Ts          time.Time `json:"ts"`
	Level       Level     `json:"level"`
	Reason      string    `json:"reason"`
	Msg         string    `json:"msg"`
	OperationID string    `json:"operationId"`
	NodeID      string    `json:"nodeId"`
}

Event is a single lifecycle milestone written to a JSONL file. All fields are required; Log rejects an Event with any zero value.

type EventLogger

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

EventLogger appends JSON lines to a single file, safe for concurrent use. Each Log call fsyncs so entries survive a daemon crash.

func NewAppend

func NewAppend(dir, fileName string) (*EventLogger, error)

NewAppend opens (or creates) a fixed append-only JSONL file in dir named fileName. Used for migration events where multiple operations share one file. fileName must be a plain filename with no path separators.

func NewOperation

func NewOperation(dir, operationID string) (*EventLogger, error)

NewOperation creates a per-operation JSONL file in dir named "consensus-<operationID>.jsonl" and returns a logger. The file is truncated on open so each operation starts fresh. The caller must call Close when done. operationID must not contain path separators or be an absolute path.

func (*EventLogger) Close

func (l *EventLogger) Close() error

Close flushes and closes the underlying file.

func (*EventLogger) Log

func (l *EventLogger) Log(e Event) error

Log validates e, appends one JSON line to the file, and fsyncs. Returns an error if any required field is empty, or if marshalling or I/O fails. The caller decides whether to halt or continue on error.

func (*EventLogger) Path

func (l *EventLogger) Path() string

Path returns the absolute path of the underlying JSONL file.

type Level

type Level string

Level is the severity of a lifecycle milestone — mirrors HIP-defined values. Three levels are defined: INFO for a milestone that happened, ERROR for one that failed terminally, and WARN for a milestone that completed in a degraded or policy-notable way — an optional artifact skipped, or a safety check deliberately bypassed. WARN is not for retries, backoff, or transient errors; those, like all operational states, belong in journald, not here. DEBUG has no place in a sparse milestone audit trail.

const (
	LevelInfo  Level = "INFO"
	LevelWarn  Level = "WARN"
	LevelError Level = "ERROR"
)

Jump to

Keyboard shortcuts

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