sxcli.dev/fw/sink/console
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:
import _ "sxcli.dev/fw/sink/console"Index#
- Constants
- type Config
- type Console
- func (s *Console) Configured() error
- func (s *Console) Enabled(ctx context.Context, level slog.Level) bool
- func (s *Console) Handle(ctx context.Context, record slog.Record) error
- func (s *Console) Start() error
- func (s *Console) Stop() error
- func (s *Console) WithAttrs(attrs []slog.Attr) slog.Handler
- func (s *Console) WithGroup(name string) slog.Handler
Constants#
const ID = "sxcli.dev/fw/sink/console"
type Configsrc#
Config is the console sink configuration, section "console".
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.
type Console struct { // contains filtered or unexported fields }
func (*Console) Configuredsrc#
func (s *Console) Configured() error
Configured builds the inner handler from the merged configuration.
func (*Console) Enabledsrc#
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#
func (s *Console) Handle(ctx context.Context, record slog.Record) error
Handle delegates to the inner handler.
func (*Console) Startsrc#
func (s *Console) Start() error
Start is a no-op: the console needs no acquisition.
func (*Console) Stopsrc#
func (s *Console) Stop() error
Stop is a no-op: stderr and stdout are not ours to close.
func (*Console) WithAttrssrc#
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#
func (s *Console) WithGroup(name string) slog.Handler
WithGroup returns a derived view sharing the underlying output.