Help us shape the future of Go! Take the 2026 Go Developer Survey

session

package
v0.39.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultLogPath

func DefaultLogPath(dir string) string

DefaultLogPath returns a timestamped session log path inside dir.

func ErrorData

func ErrorData(message string, details map[string]any) map[string]any

ErrorData returns event data for an error.

func GraderResultData

func GraderResultData(graderName, graderType string, passed bool, score float64, feedback string) map[string]any

GraderResultData returns event data for a grader result.

func RenderTimeline

func RenderTimeline(w io.Writer, events []Event)

RenderTimeline writes a human-readable session timeline to w.

func SessionCompleteData

func SessionCompleteData(totalTests, passed, failed, errors int, durationMs int64) map[string]any

SessionCompleteData returns event data for a session end.

func SessionStartData

func SessionStartData(specPath, model, engine string, taskCount int) map[string]any

SessionStartData returns event data for a session start.

func TaskCompleteData

func TaskCompleteData(taskName, status string, score float64, durationMs int64) map[string]any

TaskCompleteData returns event data for a task completion.

func TaskStartData

func TaskStartData(taskName string, taskNum, totalTasks int) map[string]any

TaskStartData returns event data for a task start.

Types

type Event

type Event struct {
	Timestamp time.Time      `json:"timestamp"`
	Type      EventType      `json:"type"`
	Data      map[string]any `json:"data,omitempty"`
}

Event is a single timestamped entry in a session log.

func NewEvent

func NewEvent(t EventType, data map[string]any) Event

NewEvent creates an event with the current timestamp.

func ReadEvents

func ReadEvents(path string) ([]Event, error)

ReadEvents parses all events from a session log file.

type EventType

type EventType string

EventType identifies the kind of session event.

const (
	EventSessionStart EventType = "session_start"
	EventSessionEnd   EventType = "session_complete"
	EventTaskStart    EventType = "task_start"
	EventTaskComplete EventType = "task_complete"
	EventRunComplete  EventType = "run_complete"
	EventGraderResult EventType = "grader_result"
	EventError        EventType = "error"
)

type JSONLogger

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

JSONLogger writes events as newline-delimited JSON (NDJSON).

func NewJSONLogger

func NewJSONLogger(path string) (*JSONLogger, error)

NewJSONLogger creates a logger that writes NDJSON to the given path. Parent directories are created automatically.

func (*JSONLogger) Close

func (l *JSONLogger) Close() error

Close flushes and closes the underlying file.

func (*JSONLogger) Log

func (l *JSONLogger) Log(event Event) error

Log writes a single event as one JSON line.

func (*JSONLogger) Path

func (l *JSONLogger) Path() string

Path returns the file path of the session log.

type Logger

type Logger interface {
	Log(event Event) error
	Close() error
}

Logger defines the interface for session event logging.

type NopLogger

type NopLogger struct{}

NopLogger discards all events. Useful as a default when logging is disabled.

func (NopLogger) Close

func (NopLogger) Close() error

Close is a no-op.

func (NopLogger) Log

func (NopLogger) Log(Event) error

Log is a no-op.

type SessionFile

type SessionFile struct {
	Path      string
	Name      string
	Size      int64
	ModTime   time.Time
	NumEvents int
}

SessionFile represents a session log file on disk.

func ListSessions

func ListSessions(dir string) ([]SessionFile, error)

ListSessions finds .jsonl session log files in dir.

Jump to

Keyboard shortcuts

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