logging

package
v0.1.26 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxBufferSize is the maximum number of log entries to keep in memory
	MaxBufferSize = 10000

	// LogLevelDebug represents debug-level logs
	LogLevelDebug = "debug"
	// LogLevelInfo represents info-level logs
	LogLevelInfo = "info"
	// LogLevelWarn represents warning-level logs
	LogLevelWarn = "warn"
	// LogLevelError represents error-level logs
	LogLevelError = "error"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LogEntry

type LogEntry struct {
	ID        string                 `json:"id"`
	Timestamp time.Time              `json:"timestamp"`
	Level     string                 `json:"level"`
	Source    string                 `json:"source"`
	Message   string                 `json:"message"`
	Metadata  map[string]interface{} `json:"metadata,omitempty"`
}

LogEntry represents a single log entry

type Manager

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

Manager handles log collection, buffering, and persistence

func NewManager

func NewManager(db *sql.DB) *Manager

NewManager creates a new logging manager

func (*Manager) AddHandler

func (m *Manager) AddHandler(handler func(LogEntry))

AddHandler registers a handler to be called for each new log entry (for SSE)

func (*Manager) Debug

func (m *Manager) Debug(source, message string, metadata map[string]interface{})

Debug logs a debug-level message

func (*Manager) Error

func (m *Manager) Error(source, message string, metadata map[string]interface{})

Error logs an error-level message

func (*Manager) GetRecent

func (m *Manager) GetRecent(limit int, levelFilter, sourceFilter, agentID, beadID, projectID string, since, until time.Time) []LogEntry

GetRecent returns the most recent log entries from the buffer

func (*Manager) Info

func (m *Manager) Info(source, message string, metadata map[string]interface{})

Info logs an info-level message

func (*Manager) InstallLogInterceptor added in v0.1.2

func (m *Manager) InstallLogInterceptor()

InstallLogInterceptor redirects Go's standard log package through this manager. Call this once at startup after creating the manager.

func (*Manager) Log

func (m *Manager) Log(level, source, message string, metadata map[string]interface{})

Log adds a log entry to the buffer and optionally persists it

func (*Manager) Query

func (m *Manager) Query(limit int, levelFilter, sourceFilter, agentID, beadID, projectID string, since, until time.Time) ([]LogEntry, error)

Query returns log entries from the database based on filters

func (*Manager) Warn

func (m *Manager) Warn(source, message string, metadata map[string]interface{})

Warn logs a warning-level message

Jump to

Keyboard shortcuts

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