logging

package
v0.17.18 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLogPath

func GetLogPath() string

GetLogPath returns the path to the log file in the state directory. Does not create directories — pure path computation.

func LogRequestPayload

func LogRequestPayload(payload []byte, provider, model string, streaming bool)

LogRequestPayload saves the exact JSON payload sent to the provider. It writes both the canonical lastRequest.json and a timestamped diagnostic copy. All payloads are redacted via pkg/redact to prevent credential leakage in log files.

func LogRequestPayloadOnError

func LogRequestPayloadOnError(payload []byte, provider, model string, streaming bool, errorType string, err error)

LogRequestPayloadOnError saves the JSON payload only when an error occurs. It writes to lastRequest.json and a timestamped file with error context. All payloads are redacted via pkg/redact to prevent credential leakage in log files.

func WriteLocalCopy

func WriteLocalCopy(filename string, content []byte)

WriteLocalCopy writes a copy of content to a local diagnostic file for debugging

func WriteLocalCopyRequest

func WriteLocalCopyRequest(filename string, data []byte)

WriteLocalCopy optionally mirrors log files to the current working directory.

Types

type Logger

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

Logger provides structured logging functionality

func NewLogger

func NewLogger() (*Logger, error)

NewLogger creates a new logger instance

func (*Logger) Close

func (l *Logger) Close() error

Close closes the log file

func (*Logger) Debug

func (l *Logger) Debug(format string, args ...interface{})

Debug logs debug information

func (*Logger) Error

func (l *Logger) Error(format string, args ...interface{})

Error logs error messages

func (*Logger) Info

func (l *Logger) Info(format string, args ...interface{})

Info logs informational messages

func (*Logger) Log

func (l *Logger) Log(level string, format string, args ...interface{})

Log writes a log message with timestamp

func (*Logger) Warn

func (l *Logger) Warn(format string, args ...interface{})

Warn logs warning messages

type StructuredLogger

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

StructuredLogger wraps slog.Logger with domain-specific convenience methods for consistent structured logging throughout the agent codebase.

var Default *StructuredLogger

Default is the global logger instance initialized on first use

func NewStructuredLogger

func NewStructuredLogger() *StructuredLogger

NewStructuredLogger creates a new logger writing to stderr with JSON handler

func (*StructuredLogger) Debug

func (l *StructuredLogger) Debug(msg string, args ...interface{})

Debug logs at debug level

func (*StructuredLogger) Error

func (l *StructuredLogger) Error(msg string, args ...interface{})

Error logs at error level

func (*StructuredLogger) Info

func (l *StructuredLogger) Info(msg string, args ...interface{})

Info logs at info level

func (*StructuredLogger) Warn

func (l *StructuredLogger) Warn(msg string, args ...interface{})

Warn logs at warn level

func (*StructuredLogger) WithContext

func (l *StructuredLogger) WithContext(sessionID, chatID, clientID string) *StructuredLogger

WithContext returns a logger with session/conversation context

func (*StructuredLogger) WithError

func (l *StructuredLogger) WithError(err error) *StructuredLogger

WithError returns a logger with error context

func (*StructuredLogger) WithField

func (l *StructuredLogger) WithField(key string, value interface{}) *StructuredLogger

WithField adds an arbitrary key-value pair

func (*StructuredLogger) WithProvider

func (l *StructuredLogger) WithProvider(provider, model string) *StructuredLogger

WithProvider returns a logger with provider/model context

func (*StructuredLogger) WithTool

func (l *StructuredLogger) WithTool(toolName, toolID string) *StructuredLogger

WithTool returns a logger with tool execution context

Jump to

Keyboard shortcuts

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