Documentation
¶
Index ¶
- Constants
- func LogDeploymentComplete(logger *slog.Logger, domains []string, deploymentID, appName, message string)
- func LogDeploymentFailed(logger *slog.Logger, deploymentID, appName, message string, err error)
- func LogFatal(logger *slog.Logger, message string, args ...any)
- func NewDeploymentLogger(deploymentID string, level slog.Level, publisher StreamPublisher) *slog.Logger
- func NewLogger(level slog.Level, publisher StreamPublisher) *slog.Logger
- func NewStreamHandler(publisher StreamPublisher, next slog.Handler) slog.Handler
- type LogBroker
- func (lb *LogBroker) Close()
- func (lb *LogBroker) Publish(entry LogEntry)
- func (lb *LogBroker) SubscribeDeployment(deploymentID string) <-chan LogEntry
- func (lb *LogBroker) SubscribeGeneral() (<-chan LogEntry, string)
- func (lb *LogBroker) UnsubscribeDeployment(deploymentID string)
- func (lb *LogBroker) UnsubscribeGeneral(subscriberID string)
- type LogEntry
- type StreamHandler
- type StreamPublisher
Constants ¶
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 ¶
LogDeploymentFailed marks a deployment as failed This sends the failure signal that tells CLI clients to stop streaming with error
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 ¶
Publish publishes a log entry to the general stream and deployment-specific streams
func (*LogBroker) SubscribeDeployment ¶
SubscribeDeployment creates a new subscription for a deployment ID
func (*LogBroker) SubscribeGeneral ¶
SubscribeGeneral creates a subscription for all logs and returns the channel and subscriber ID
func (*LogBroker) UnsubscribeDeployment ¶
UnsubscribeDeployment removes a deployment subscriber
func (*LogBroker) UnsubscribeGeneral ¶
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
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