sxcli.devSimple Extensible CLI

sxcli.dev/fw/sink/syslog

go
go
import "sxcli.dev/fw/sink/syslog"

Package syslog provides the syslog log sink: a slog.Handler service writing records to the local syslog socket (default) or a remote syslog server. Under systemd the local socket is journald, so records land in journalctl with severity and tag intact — no dedicated journal protocol needed for ingestion. It is an ordinary service — cold until an applet requires it or the operator enables it:

code
text
import _ "sxcli.dev/fw/sink/syslog"
// then: mybox applet --enable syslog

The sink is unavailable on non-unix platforms: importing the package there is harmless and registers nothing.

Caveat: the stdlib syslog writer exposes no write deadlines, so a remote tcp target cannot fully honor the prompt-Handle sink contract; the local socket (the default) is unaffected.

Index#

Constants#

ID is the syslog sink's identity; operators call it "syslog". The sink is unix-only; the identity is portable.

go
go
const ID = "sxcli.dev/fw/sink/syslog"

type Configsrc#

Config is the syslog sink configuration, section "syslog".

go
go
type Config struct {
    Version  uint32 `json:"version"`
    Level    string `json:"level" conf:"syslog-level" usage:"minimum level logged to syslog (debug, info, warn, error)"`
    Format   string `json:"format" conf:"syslog-format" usage:"syslog message format: text or json"`
    Tag      string `json:"tag" conf:"syslog-tag" usage:"syslog tag; defaults to the process name"`
    Facility string `json:"facility" conf:"syslog-facility" usage:"syslog facility (daemon, user, auth, local0..local7, ...)"`
    Network  string `json:"network" conf:"syslog-network" usage:"remote syslog network (udp, tcp); empty means the local socket"`
    Address  string `json:"address" conf:"syslog-address" usage:"remote syslog address as host:port; set together with network"`
}

type Syslogsrc#

Syslog is the sink service. Severity travels per message, so Handle renders the record through the inner formatter into a guarded buffer and emits the line with the severity mapped from the record level. The formatter drops time= and level= — syslog stamps both itself.

go
go
type Syslog struct {
    // contains filtered or unexported fields
}

func (*Syslog) Configuredsrc#

go
go
func (s *Syslog) Configured() error

Configured validates the configuration and — as its last act — dials the syslog socket and builds the inner formatter, so the sink is operational for the buffer replay at the multihandler swap.

func (*Syslog) Enabledsrc#

go
go
func (s *Syslog) Enabled(ctx context.Context, level slog.Level) bool

Enabled reports whether the record would be logged; an unconfigured sink accepts nothing.

func (*Syslog) Handlesrc#

go
go
func (s *Syslog) Handle(ctx context.Context, record slog.Record) error

Handle delegates to the shared delivery path.

func (*Syslog) Startsrc#

go
go
func (s *Syslog) Start() error

Start is a no-op: the socket was dialed in Configured so the sink could capture the startup replay. The sink stays a Starter because only started Starters receive Stop.

func (*Syslog) Stopsrc#

go
go
func (s *Syslog) Stop() error

Stop closes the syslog connection.

func (*Syslog) WithAttrssrc#

go
go
func (s *Syslog) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs returns a derived view sharing the connection, per the sink-author contract.

func (*Syslog) WithGroupsrc#

go
go
func (s *Syslog) WithGroup(name string) slog.Handler

WithGroup returns a derived view sharing the connection.