cmdlogger

package
v2.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasErrored

func HasErrored() bool

HasErrored returns true if there have been any calls to Handle with a level of slog.LevelError, assuming the logger is a Handler.

If the logger is not a Handler, this will always return false.

func Levels

func Levels() []string

func ParseLevel

func ParseLevel(text string) (slog.Level, error)

func SendEverythingToStderr

func SendEverythingToStderr()

SendEverythingToStderr tells the logger (if its in use) to send all logs to stderr regardless of their level.

This is useful if we're expecting to output structured data to stdout such as JSON, which cannot be mixed with other output.

func SetLevel

func SetLevel(level slog.Leveler)

Types

type CmdLogger

type CmdLogger interface {
	slog.Handler
	SendEverythingToStderr()
	HasErrored() bool
	SetLevel(level slog.Leveler)
}

func New

func New(stdout, stderr io.Writer) CmdLogger

type Handler added in v2.0.2

type Handler struct {
	Level slog.Leveler
	// contains filtered or unexported fields
}

func (*Handler) Enabled added in v2.0.2

func (c *Handler) Enabled(_ context.Context, level slog.Level) bool

func (*Handler) Handle added in v2.0.2

func (c *Handler) Handle(_ context.Context, record slog.Record) error

func (*Handler) HasErrored added in v2.0.2

func (c *Handler) HasErrored() bool

HasErrored returns true if there have been any calls to Handle with a level of slog.LevelError

func (*Handler) SendEverythingToStderr added in v2.0.2

func (c *Handler) SendEverythingToStderr()

SendEverythingToStderr tells the logger to send all logs to stderr regardless of their level.

This is useful if we're expecting to output structured data to stdout such as JSON, which cannot be mixed with other output.

func (*Handler) SetLevel added in v2.0.2

func (c *Handler) SetLevel(level slog.Leveler)

func (*Handler) WithAttrs added in v2.0.2

func (c *Handler) WithAttrs(_ []slog.Attr) slog.Handler

func (*Handler) WithGroup added in v2.0.2

func (c *Handler) WithGroup(_ string) slog.Handler

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL