townlog

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package townlog provides centralized logging for Gas Town agent lifecycle events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Timestamp time.Time `json:"timestamp"`
	Type      EventType `json:"type"`
	Agent     string    `json:"agent"`             // e.g., "gastown/crew/max" or "gastown/polecats/Toast"
	Context   string    `json:"context,omitempty"` // Additional context (issue ID, error message, etc.)
}

Event represents a single agent lifecycle event.

func FilterEvents

func FilterEvents(events []Event, f Filter) []Event

FilterEvents applies a filter to events.

func ParseLogLines

func ParseLogLines(content string) ([]Event, error)

ParseLogLines parses log lines back into Events. This is the inverse of formatLogLine for filtering.

func ReadEvents

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

ReadEvents reads all events from the log file. Useful for filtering and analysis.

func TailEvents

func TailEvents(townRoot string, n int) ([]Event, error)

TailEvents returns the last n events from the log.

type EventType

type EventType string

EventType represents the type of agent lifecycle event.

const (
	// EventSpawn indicates a new agent was created.
	EventSpawn EventType = "spawn"
	// EventWake indicates an agent was resumed.
	EventWake EventType = "wake"
	// EventNudge indicates a message was injected into an agent.
	EventNudge EventType = "nudge"
	// EventHandoff indicates an agent handed off to a fresh session.
	EventHandoff EventType = "handoff"
	// EventDone indicates an agent finished its work.
	EventDone EventType = "done"
	// EventCrash indicates an agent exited unexpectedly.
	EventCrash EventType = "crash"
	// EventKill indicates an agent was killed intentionally.
	EventKill EventType = "kill"
	// EventCallback indicates a callback was processed during patrol.
	EventCallback EventType = "callback"

	// Witness patrol events
	EventPatrolStarted  EventType = "patrol_started"
	EventPolecatChecked EventType = "polecat_checked"
	EventPolecatNudged  EventType = "polecat_nudged"
	EventEscalationSent EventType = "escalation_sent"
	EventPatrolComplete EventType = "patrol_complete"
)

type Filter

type Filter struct {
	Type  EventType // Filter by event type (empty for all)
	Agent string    // Filter by agent prefix (empty for all)
	Since time.Time // Filter by time (zero for all)
}

FilterEvents returns events matching the filter criteria.

type Logger

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

Logger handles writing events to the town log file.

func NewLogger

func NewLogger(townRoot string) *Logger

NewLogger creates a new Logger for the given town root.

func (*Logger) Log

func (l *Logger) Log(eventType EventType, agent, context string) error

Log is a convenience method that creates an Event and logs it.

func (*Logger) LogEvent

func (l *Logger) LogEvent(event Event) error

LogEvent logs a single event to the town log.

Jump to

Keyboard shortcuts

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