Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterRoutes ¶
func RegisterRoutes(e *echo.Echo, buffer *RingBuffer, authMiddleware *auth.Middleware)
RegisterRoutes registers the log viewer endpoint.
Types ¶
type ListLogsQuery ¶
type ListLogsQuery struct {
Level *string `query:"level" json:"level,omitempty" validate:"omitempty,oneof=debug info warn error"`
Search *string `query:"search" json:"search,omitempty"`
Limit *int `query:"limit" json:"limit,omitempty" validate:"omitempty,min=1,max=1000"`
AfterID *uint64 `query:"after_id" json:"after_id,omitempty"`
}
ListLogsQuery defines query parameters for GET /logs.
type LogEntry ¶
type LogEntry struct {
ID uint64 `json:"id"`
Level string `json:"level"`
Timestamp time.Time `json:"timestamp"`
Message string `json:"message"`
Data map[string]any `json:"data,omitempty"`
Error *string `json:"error,omitempty"`
}
LogEntry represents a parsed log entry stored in the ring buffer.
type RingBuffer ¶
type RingBuffer struct {
// contains filtered or unexported fields
}
RingBuffer captures zerolog JSON output into a fixed-size circular buffer. It implements io.Writer so it can be used with io.MultiWriter.
func NewRingBuffer ¶
func NewRingBuffer(capacity int, broker *events.Broker) *RingBuffer
NewRingBuffer creates a ring buffer that stores up to capacity log entries. If broker is non-nil, each new entry is published as a "log.entry" SSE event.
func (*RingBuffer) Query ¶
func (rb *RingBuffer) Query(level, search string, limit int, afterID uint64) []LogEntry
Query returns log entries matching the given filters. level: minimum severity ("debug", "info", "warn", "error"). Empty = all. search: case-insensitive substring match on message. Empty = all. limit: max entries to return. 0 = no limit. afterID: return entries with ID > afterID. 0 = all.