sessionlog

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package sessionlog tees a session's records into an append-only per-session file under .remindb/logs/.

Index

Constants

View Source
const (

	// Tool-call trace messages emitted by tools.Deps.logCall.
	MsgToolCall       = "mcp call"
	MsgToolCallFailed = "mcp call failed"
)

Variables

This section is empty.

Functions

func Dir

func Dir(workspace string) string

Dir returns the per-session log directory under workspace.

func FromContext

func FromContext(ctx context.Context) string

func NewContext

func NewContext(ctx context.Context, id string) context.Context

NewContext returns ctx carrying the canonical session id the registry resolved.

func Slug

func Slug(id string) string

Slug reduces a session id to its filesystem-safe logfile stem; ids are UUID/hex in practice.

Types

type Handler

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

func NewHandler

func NewHandler(next slog.Handler, sink *Sink) *Handler

NewHandler wraps next as the outermost handler, teeing captured records to sink.

func (*Handler) Enabled

func (h *Handler) Enabled(context.Context, slog.Level) bool

Enabled stays permissive: the session file captures Debug tool traces even when the shared stream is at Info.

func (*Handler) Handle

func (h *Handler) Handle(ctx context.Context, r slog.Record) error

func (*Handler) WithAttrs

func (h *Handler) WithAttrs(as []slog.Attr) slog.Handler

func (*Handler) WithGroup

func (h *Handler) WithGroup(name string) slog.Handler

type Record

type Record struct {
	Time   time.Time      `json:"time"`
	Level  string         `json:"level"`
	Msg    string         `json:"msg"`
	Fields map[string]any `json:"fields,omitempty"`
}

func ParseLog

func ParseLog(r io.Reader) ([]Record, error)

ParseLog reads JSONL session-log records in append order.

type Sink

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

func New

func New(workspace string, maxFileSize int64) (*Sink, error)

New creates <workspace>/.remindb/logs and returns a sink bounded by maxFileSize bytes.

func (*Sink) Write

func (s *Sink) Write(sessionID string, line []byte) error

Write appends line to the file keyed by sessionID, rotating once when the cap is reached.

Jump to

Keyboard shortcuts

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