journal

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionHTTPRequest  = "http.request"
	ActionHTTPResponse = "http.response"
	ActionHTTPError    = "http.error"
)
View Source
const ActionUIRender = "ui.render"

ActionUIRender is for an event that indicates we wrote output to the UI

View Source
const RecorderKey contextKey = "journal-recorder"

Variables

This section is empty.

Functions

func ContextWithRecorder

func ContextWithRecorder(ctx context.Context, recorder Recorder) context.Context

ContextWithRecorder adds the recorder to the given context

Types

type Event

type Event struct {
	Timestamp time.Time `json:"timestamp"`
	Action    string    `json:"action"`
	Payload   any       `json:"payload,omitempty"`
}

func ParseEvents

func ParseEvents(r io.Reader) ([]*Event, error)

ParseEvents will read the events from the reader

func ParseEventsFromFile

func ParseEventsFromFile(p string) ([]*Event, error)

ParseEventsFromFile will read the events from the given file path

func (*Event) GetString

func (e *Event) GetString(key string) (string, bool)

GetString is a helper to get a string value from the Payload

type FileRecorder

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

FileRecorder writes a structured log of the agent's actions and observations to a file.

func NewFileRecorder

func NewFileRecorder(path string) (*FileRecorder, error)

NewFileRecorder creates a new FileRecorder that writes to the given file.

func (*FileRecorder) Close

func (r *FileRecorder) Close() error

Close closes the file.

func (*FileRecorder) Write

func (r *FileRecorder) Write(ctx context.Context, event *Event) error

type LogRecorder

type LogRecorder struct {
}

func (*LogRecorder) Close

func (r *LogRecorder) Close() error

func (*LogRecorder) Write

func (r *LogRecorder) Write(ctx context.Context, event *Event) error

type Recorder

type Recorder interface {
	io.Closer

	// Write will add an event to the recorder.
	Write(ctx context.Context, event *Event) error
}

Recorder is an interface for recording a structured log of the agent's actions and observations.

func RecorderFromContext

func RecorderFromContext(ctx context.Context) Recorder

RecorderFromContext extracts the recorder from the given context

Source Files

  • context.go
  • loader.go
  • log.go
  • recorder.go

Jump to

Keyboard shortcuts

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