Documentation
¶
Overview ¶
Package logsink provides a shared Unix-domain-socket writer for Alpamon plugins. Plugins use this package as an io.Writer target for zerolog so that their logs are forwarded to Alpamon and then on to the Alpacon server, without each plugin duplicating the filtering, framing, and reconnect logic.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SocketPath ¶
func SocketPath() string
SocketPath returns the UDS path for the Alpamon log socket.
The path is derived from utils.RunDir(), which differs by uid: /run/alpamon for root, /tmp/alpamon for non-root. This is safe today because both Alpamon and its plugins run as root; once privilege separation lands, this should switch to a fixed system path so non-root plugins still reach the daemon's socket.
Types ¶
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is a zerolog-compatible io.Writer that forwards filtered log records to alpamon over a Unix domain socket using the length-prefix wire protocol.
Each Write call parses the zerolog JSON line, checks whether the source file and level pass the plugin-specific handlers filter, builds a LogRecord, and sends it framed as [uint32 BE length][JSON body]. Connection errors are silent and the writer reconnects automatically after a short cooldown.
func New ¶
New returns a Writer for the given plugin. program is used as the LogRecord.Program field. handlers maps base filenames to their minimum log level threshold (using Python logging levels: 10=DEBUG, 20=INFO, 30=WARNING, 40=ERROR, 50=CRITICAL). Connection failure at construction time is non-fatal; the writer will retry.