Documentation
¶
Overview ¶
Package logging provides structured logging sinks for BOOTy.
Index ¶
- type KafkaConfig
- type KafkaHandler
- func (h *KafkaHandler) Close() error
- func (h *KafkaHandler) Enabled(_ context.Context, level slog.Level) bool
- func (h *KafkaHandler) Handle(_ context.Context, r slog.Record) error
- func (h *KafkaHandler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *KafkaHandler) WithGroup(name string) slog.Handler
- type LogMessage
- type MachineIdentity
- type MessageWriter
- type MultiHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KafkaConfig ¶
type KafkaConfig struct {
Brokers []string `json:"brokers"`
Topic string `json:"topic"`
TLS bool `json:"tls,omitempty"`
SASLUser string `json:"saslUser,omitempty"`
SASLPassword string `json:"-"`
SASLMechanism string `json:"saslMechanism,omitempty"` // "PLAIN", "SCRAM-SHA-256", "SCRAM-SHA-512".
Compression string `json:"compression,omitempty"` // "snappy", "lz4", "zstd", "none".
}
KafkaConfig holds Kafka connection settings.
func (*KafkaConfig) Validate ¶
func (c *KafkaConfig) Validate() error
Validate checks KafkaConfig for required fields.
type KafkaHandler ¶
type KafkaHandler struct {
// contains filtered or unexported fields
}
KafkaHandler implements slog.Handler for structured log output.
func NewKafkaHandler ¶
func NewKafkaHandler(writer MessageWriter, topic string, identity MachineIdentity) *KafkaHandler
NewKafkaHandler creates a structured logging handler.
func (*KafkaHandler) Close ¶
func (h *KafkaHandler) Close() error
Close flushes and closes the underlying writer.
func (*KafkaHandler) Enabled ¶
Enabled reports whether the handler handles records at the given level.
type LogMessage ¶
type LogMessage struct {
Timestamp time.Time `json:"timestamp"`
Level string `json:"level"`
Message string `json:"message"`
MachineSerial string `json:"machineSerial,omitempty"`
BMCMAC string `json:"bmcMac,omitempty"`
ProvisioningID string `json:"provisioningId,omitempty"`
Step string `json:"step,omitempty"`
Attrs map[string]any `json:"attrs,omitempty"`
}
LogMessage is the structured Kafka message format.
type MachineIdentity ¶
MachineIdentity holds machine identification for log enrichment.
type MessageWriter ¶
type MessageWriter interface {
WriteMessage(topic string, key string, data []byte) error
Close() error
}
MessageWriter is the interface for sending log messages.
func NewWriterAdapter ¶
func NewWriterAdapter(w io.Writer) MessageWriter
NewWriterAdapter creates a MessageWriter that writes JSON lines to w.
type MultiHandler ¶
type MultiHandler struct {
// contains filtered or unexported fields
}
MultiHandler fans out log records to multiple handlers.
func NewMultiHandler ¶
func NewMultiHandler(handlers ...slog.Handler) *MultiHandler
NewMultiHandler creates a handler that sends to all given handlers.