sxcli.devSimple Extensible CLI

sxcli.dev/fw/sink/console

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

Package console provides the console log sink: a slog.Handler service writing text or json records to stderr (default) or stdout. It is an opt-in service — enabled with --enable console or pulled by a dependency; a binary that imports it but enables nothing falls to the framework's raw stderr logging floor:

code
text
import _ "sxcli.dev/fw/sink/console"

Index#

Constants#

ID is the console sink's identity; operators call it "console".

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

type Configsrc#

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

go
go
type Config struct {
    Version uint32 `json:"version"`
    Level   string `json:"level" conf:"console-level" usage:"minimum level logged to the console (debug, info, warn, error)"`
    Format  string `json:"format" conf:"console-format" usage:"console log format: text or json"`
    Output  string `json:"output" conf:"console-output" usage:"console log destination: stderr or stdout"`
}

type Consolesrc#

Console is the sink service. Until Configured builds the inner handler the sink is inert: disabled, handling nothing.

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

func (*Console) Configuredsrc#

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

Configured builds the inner handler from the merged configuration.

func (*Console) Enabledsrc#

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

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

func (*Console) Handlesrc#

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

Handle delegates to the inner handler.

func (*Console) Startsrc#

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

Start is a no-op: the console needs no acquisition.

func (*Console) Stopsrc#

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

Stop is a no-op: stderr and stdout are not ours to close.

func (*Console) WithAttrssrc#

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

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

func (*Console) WithGroupsrc#

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

WithGroup returns a derived view sharing the underlying output.