logging

package
v0.0.0-...-1d32ed5 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package logging configures structured logging via log/slog with optional log-file rotation via lumberjack.

Index

Constants

View Source
const MaxPromptPreviewChars = 40
View Source
const MaxPromptPreviewWords = 8

Variables

This section is empty.

Functions

func DefaultLogPath

func DefaultLogPath() string

DefaultLogPath returns the standard daemon log file location.

func ParseLevel

func ParseLevel(s string) slog.Level

ParseLevel maps a string to an slog.Level. Unrecognised values map to LevelInfo.

func PromptPreview

func PromptPreview(prompt string) string

func Setup

func Setup(mode Mode, levelStr string, logPath string) *slog.Logger

Setup creates and returns a configured *slog.Logger and sets it as the slog default.

ModeForeground produces a TextHandler writing to stderr. ModeService produces a JSONHandler writing to a lumberjack-rotated log file. If the log directory cannot be created in ModeService, it falls back to JSON on stderr.

func TaskAttrs

func TaskAttrs(task *protocol.Task) []any

TaskAttrs returns slog attributes for consistent log correlation from a Task message.

Types

type Mode

type Mode int

Mode selects logging output.

const (
	// ModeForeground writes human-readable text to stderr.
	ModeForeground Mode = iota
	// ModeService writes JSON to a rotated log file.
	ModeService
)

type TaskLifecycleLogEvent

type TaskLifecycleLogEvent struct {
	Event         string `json:"event"`
	Phase         string `json:"phase"`
	Status        string `json:"status,omitempty"`
	TaskID        string `json:"taskId,omitempty"`
	SessionID     string `json:"sessionId,omitempty"`
	ChannelID     string `json:"channelId,omitempty"`
	RequestID     string `json:"requestId,omitempty"`
	TraceID       string `json:"traceId,omitempty"`
	AttemptID     string `json:"attemptId,omitempty"`
	AttemptNumber int    `json:"attemptNumber,omitempty"`
	TurnKind      string `json:"turnKind,omitempty"`
	ElapsedMs     int64  `json:"elapsedMs,omitempty"`
	Model         string `json:"model,omitempty"`
	Provider      string `json:"provider,omitempty"`
	PID           int    `json:"pid,omitempty"`
	FailureCode   string `json:"failureCode,omitempty"`
	Retryable     bool   `json:"retryable,omitempty"`
	PromptPreview string `json:"promptPreview,omitempty"`
	Cleanup       string `json:"cleanup,omitempty"`
}

func NewTaskLifecycleLog

func NewTaskLifecycleLog(input TaskLifecycleLogInput) TaskLifecycleLogEvent

type TaskLifecycleLogInput

type TaskLifecycleLogInput struct {
	Phase         string
	Status        string
	TaskID        string
	SessionID     string
	ChannelID     string
	RequestID     string
	TraceID       string
	AttemptID     string
	AttemptNumber int
	TurnKind      string
	ElapsedMs     int64
	Model         string
	Provider      string
	PID           int
	FailureCode   string
	Retryable     bool
	PromptText    string
	Cleanup       string
}

Jump to

Keyboard shortcuts

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