logging

package
v0.1.0-beta.48 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Deployment attributes
	AttrDeploymentID       = "deploymentID"
	AttrDeploymentComplete = "deploymentComplete"
	AttrDeploymentFailed   = "deploymentFailed"
	AttrDeploymentSuccess  = "deploymentSuccess"

	// haloyd attributes
	AttrHaloydInitComplete = "haloydInitComplete"

	// App attributes
	AttrAppName = "appName"
	AttrApp     = "app"
	AttrDomains = "domains"

	// General attributes
	AttrError = "error"
)

Log attribute keys used for structured logging and streaming

Variables

This section is empty.

Functions

func LogDeploymentComplete

func LogDeploymentComplete(logger *slog.Logger, domains []string, deploymentID, appName, message string)

LogDeploymentComplete marks a deployment as successfully completed This sends the completion signal that tells CLI clients to stop streaming

func LogDeploymentFailed

func LogDeploymentFailed(logger *slog.Logger, deploymentID, appName, message string, err error)

LogDeploymentFailed marks a deployment as failed This sends the failure signal that tells CLI clients to stop streaming with error

func LogFatal

func LogFatal(logger *slog.Logger, message string, args ...any)

LogFatal logs an error and exits the program

func NewDeploymentLogger

func NewDeploymentLogger(deploymentID string, level slog.Level, publisher StreamPublisher) *slog.Logger

NewDeploymentLogger creates a logger with persistent deploymentID

func NewLogger

func NewLogger(level slog.Level, publisher StreamPublisher) *slog.Logger

NewLogger creates a new slog.Logger with optional streaming

func NewStreamHandler

func NewStreamHandler(publisher StreamPublisher, next slog.Handler) slog.Handler

NewStreamHandler creates a new streaming handler

Types

type LogBroker

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

LogBroker manages log streams for different deployment IDs

func (*LogBroker) Close

func (lb *LogBroker) Close()

Close shuts down the log broker and closes all channels

func (*LogBroker) Publish

func (lb *LogBroker) Publish(entry LogEntry)

Publish publishes a log entry to the general stream and deployment-specific streams

func (*LogBroker) SubscribeDeployment

func (lb *LogBroker) SubscribeDeployment(deploymentID string) <-chan LogEntry

SubscribeDeployment creates a new subscription for a deployment ID

func (*LogBroker) SubscribeGeneral

func (lb *LogBroker) SubscribeGeneral() (<-chan LogEntry, string)

SubscribeGeneral creates a subscription for all logs and returns the channel and subscriber ID

func (*LogBroker) UnsubscribeDeployment

func (lb *LogBroker) UnsubscribeDeployment(deploymentID string)

UnsubscribeDeployment removes a deployment subscriber

func (*LogBroker) UnsubscribeGeneral

func (lb *LogBroker) UnsubscribeGeneral(subscriberID string)

UnsubscribeGeneral removes a specific general subscriber

type LogEntry

type LogEntry struct {
	Level                string         `json:"level"`
	Message              string         `json:"message"`
	Timestamp            time.Time      `json:"timestamp"`
	DeploymentID         string         `json:"deploymentID,omitempty"`
	AppName              string         `json:"appName,omitempty"`
	Domains              []string       `json:"domains,omitempty"`
	Fields               map[string]any `json:"fields,omitempty"`
	IsDeploymentComplete bool           `json:"isDeploymentComplete,omitempty"`
	IsDeploymentFailed   bool           `json:"isDeploymentFailed,omitempty"`
	IsDeploymentSuccess  bool           `json:"isDeploymentSuccess,omitempty"`
	IsHaloydInitComplete bool           `json:"isHaloydInitComplete,omitempty"`
}

LogEntry represents a structured log entry for streaming logs

type StreamHandler

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

StreamHandler wraps another slog.Handler and publishes logs to streams

func (*StreamHandler) Enabled

func (sh *StreamHandler) Enabled(ctx context.Context, level slog.Level) bool

Enabled delegates to the next handler

func (*StreamHandler) Handle

func (sh *StreamHandler) Handle(ctx context.Context, rec slog.Record) error

Handle processes log records and publishes them to streams

func (*StreamHandler) WithAttrs

func (sh *StreamHandler) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs creates a new handler with additional persistent attributes

func (*StreamHandler) WithGroup

func (sh *StreamHandler) WithGroup(name string) slog.Handler

WithGroup creates a new handler with a group

type StreamPublisher

type StreamPublisher interface {
	Publish(entry LogEntry)

	SubscribeGeneral() (<-chan LogEntry, string)
	UnsubscribeGeneral(subscriberID string)

	SubscribeDeployment(deploymentID string) <-chan LogEntry
	UnsubscribeDeployment(deploymentID string)

	Close()
}

StreamPublisher defines the interface for publishing log entries to streams

func NewLogBroker

func NewLogBroker() StreamPublisher

NewLogBroker creates a new log broker

Jump to

Keyboard shortcuts

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