logs

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package logs provides real-time log streaming functionality.

Index

Constants

View Source
const (
	// DefaultMaxLines is the default maximum number of log lines to keep.
	DefaultMaxLines = 5000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

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

Broker manages log subscriptions and publishing.

func NewBroker

func NewBroker(logger *slog.Logger) *Broker

NewBroker creates a new log broker.

func (*Broker) Publish

func (b *Broker) Publish(entry *models.LogEntry)

Publish sends a log entry to all matching subscribers.

func (*Broker) PublishBatch

func (b *Broker) PublishBatch(entries []*models.LogEntry)

PublishBatch sends multiple log entries to all matching subscribers.

func (*Broker) Subscribe

func (b *Broker) Subscribe(ctx context.Context, appID, deploymentID, source string) *Subscriber

Subscribe creates a new subscription for log events. Returns a subscriber that can be used to receive logs.

func (*Broker) SubscriberCount

func (b *Broker) SubscriberCount() int

SubscriberCount returns the number of active subscribers.

func (*Broker) Unsubscribe

func (b *Broker) Unsubscribe(sub *Subscriber)

Unsubscribe removes a subscription.

type Container

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

Container maintains a bounded collection of log entries. It automatically removes the oldest entries when the limit is exceeded.

func NewContainer

func NewContainer(maxLines int) *Container

NewContainer creates a new log container with the specified max lines.

func (*Container) Add

func (c *Container) Add(entry *models.LogEntry)

Add adds a log entry to the container. If the container is at capacity, the oldest entry is removed.

func (*Container) AddBatch

func (c *Container) AddBatch(entries []*models.LogEntry)

AddBatch adds multiple log entries to the container.

func (*Container) Clear

func (c *Container) Clear()

Clear removes all entries from the container.

func (*Container) GetAll

func (c *Container) GetAll() []*models.LogEntry

GetAll returns all log entries in the container.

func (*Container) GetLast

func (c *Container) GetLast(n int) []*models.LogEntry

GetLast returns the last n log entries.

func (*Container) Len

func (c *Container) Len() int

Len returns the number of entries in the container.

func (*Container) MaxLines

func (c *Container) MaxLines() int

MaxLines returns the maximum number of lines the container can hold.

type Subscriber

type Subscriber struct {
	ID           string
	AppID        string
	DeploymentID string
	Source       string // "build", "runtime", or "" for all
	Ch           chan *models.LogEntry
	CreatedAt    time.Time
}

Subscriber represents a log stream subscriber.

Jump to

Keyboard shortcuts

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