logs

package
v0.4.6-beta.8 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package logs provides types and interfaces for streaming application logs to clients. It defines the core contract for structured log streaming used by the daemon, covering both real-time tailing and historical retrieval, with concrete implementations located in the internal/logs package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogChunk

type LogChunk struct {
	StreamID string     `json:"streamId"`
	LogType  string     `json:"logType"`
	Entries  []LogEntry `json:"entries"`
	EOF      bool       `json:"eof"`     // End of file
	HasMore  bool       `json:"hasMore"` // More logs available in history
	Offset   int64      `json:"offset"`  // Current offset in file
}

LogChunk represents a batch of log entries to be sent via WebSocket.

type LogEntry

type LogEntry struct {
	Time    string                 `json:"time"`
	Level   string                 `json:"level"`
	Msg     string                 `json:"msg"`
	Attrs   map[string]interface{} `json:"-"`
	RawLine string                 `json:"-"` // Original line for fallback
}

LogEntry represents a single structured log entry. This matches the slog JSON output format.

func (LogEntry) MarshalJSON

func (e LogEntry) MarshalJSON() ([]byte, error)

MarshalJSON custom marshaler to flatten Attrs into the main object.

func (*LogEntry) UnmarshalJSON

func (e *LogEntry) UnmarshalJSON(data []byte) error

UnmarshalJSON custom unmarshaler to capture all fields including dynamic ones.

type LogStreamer

type LogStreamer interface {
	StreamLogs(ctx context.Context, opts StreamOptions, sendChunk func(chunk LogChunk) error) error
}

LogStreamer defines the interface for streaming logs.

type StreamMode

type StreamMode string

StreamMode defines how logs should be streamed.

const (
	StreamModeTail       StreamMode = "tail"       // Start from end, follow new logs
	StreamModeHistorical StreamMode = "historical" // Read from offset, don't follow
)

type StreamOptions

type StreamOptions struct {
	StreamID  string
	LogType   string
	Mode      StreamMode // "tail" or "historical"
	StartFrom int64      // Byte offset to start from (0 = beginning, -1 = end)
	Limit     int        // Max entries to return (for historical mode)
	Follow    bool       // Continue tailing after reaching end (tail mode)
}

StreamOptions configures log streaming behavior.

Jump to

Keyboard shortcuts

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