logs

package
v0.5.11 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: Apache-2.0 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"`
	Path     string     `json:"path"`
	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 StreamOptions

type StreamOptions struct {
	StreamID  string
	Path      string
	StartFrom int64  // Byte offset for pagination (0 if not resuming)
	Limit     int    // Max entries to return per chunk
	Duration  string // Controls behavior: "live" = tail from now, time duration = read history then tail
}

StreamOptions configures log streaming behavior.

Jump to

Keyboard shortcuts

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