log

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package log provides append-only JSONL event logging for hook diagnostics. Events are written to .context/state/events.jsonl when enabled via event_log: true in .ctxrc. The log format is identical to webhook payloads (notify.Payload): one struct, two sinks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendEvent

func AppendEvent(event, message, sessionID string, detail *notify.TemplateRef)

AppendEvent writes a single event to the log file.

Noop when event logging is disabled in .ctxrc. Creates the state directory if it does not exist. Rotates the log when it exceeds EventLogMaxBytes. All errors are silently ignored: event logging must never break hook execution.

Parameters:

  • event: Event type (e.g., "relay", "nudge")
  • message: Human-readable description
  • sessionID: Claude session ID (may be empty)
  • detail: Optional template reference (may be nil)

func Query

func Query(opts QueryOpts) ([]notify.Payload, error)

Query reads events from the log, applying filters.

Returns an empty slice (not nil) when no events match or the log file does not exist. Malformed lines are silently skipped.

Parameters:

  • opts: Filter and limit options

Returns:

  • []notify.Payload: Matching events (newest last)
  • error: Non-nil only if the log file exists but cannot be opened

Types

type QueryOpts

type QueryOpts struct {
	Hook           string // filter by hook name (from detail)
	Session        string // filter by session ID
	Event          string // filter by event type
	Last           int    // return last N events (0 = all)
	IncludeRotated bool   // also read events.1.jsonl
}

QueryOpts controls event filtering and pagination.

Jump to

Keyboard shortcuts

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