logger

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package logger provides session logging for pi-go. Logs are written to ~/.pi-go/log/yyyy-mm-dd/session-HH-MM-SS.log

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Time    string `json:"time"`
	Type    string `json:"type"`              // "user", "llm_text", "tool_call", "tool_result", "error", "info"
	Agent   string `json:"agent,omitempty"`   // agent name (for subagents)
	Tool    string `json:"tool,omitempty"`    // tool name
	Content string `json:"content,omitempty"` // text content or error message
	Args    any    `json:"args,omitempty"`    // tool call arguments
	Session string `json:"session,omitempty"` // session ID (logged once at start)
	Model   string `json:"model,omitempty"`   // model name (logged once at start)
}

Entry represents a single log entry.

type Logger

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

Logger writes structured session log entries to a file.

func New

func New() (*Logger, error)

New creates a new session logger. Log file is created at ~/.pi-go/log/yyyy-mm-dd/session-HH-MM-SS.log

func (*Logger) Close

func (l *Logger) Close() error

Close closes the log file.

func (*Logger) Error

func (l *Logger) Error(msg string)

Error logs an error.

func (*Logger) Errorf added in v0.0.15

func (l *Logger) Errorf(format string, v ...any)

Errorf logs an error with formatting.

func (*Logger) Info

func (l *Logger) Info(msg string)

Info logs an informational message.

func (*Logger) LLMText

func (l *Logger) LLMText(agent, text string)

LLMText logs streamed LLM text.

func (*Logger) Log

func (l *Logger) Log(e Entry)

Log writes a structured entry.

func (*Logger) Path

func (l *Logger) Path() string

Path returns the log file path.

func (*Logger) SessionStart

func (l *Logger) SessionStart(sessionID, model, mode string)

SessionStart logs session metadata at the beginning.

func (*Logger) ToolCall

func (l *Logger) ToolCall(agent, tool string, args any)

ToolCall logs a tool invocation.

func (*Logger) ToolResult

func (l *Logger) ToolResult(agent, tool, content string)

ToolResult logs a tool response.

func (*Logger) UserMessage

func (l *Logger) UserMessage(prompt string)

UserMessage logs a user prompt.

Jump to

Keyboard shortcuts

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