cmdlogger

package
v2.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package cmdlogger provides wrapper for slog logging commands.

Index

Constants

This section is empty.

Variables

View Source
var (
	GlobalLogger *slog.Logger
)

Functions

func Debugf added in v2.1.0

func Debugf(msg string, args ...any)

func Errorf added in v2.1.0

func Errorf(msg string, args ...any)

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 Infof added in v2.1.0

func Infof(msg string, args ...any)

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 SetHasErrored added in v2.3.0

func SetHasErrored()

func SetLevel

func SetLevel(level slog.Leveler)

func Warnf added in v2.1.0

func Warnf(msg string, args ...any)

Types

type CmdLogger

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

func New

func New(stdout, stderr io.Writer) CmdLogger

func NewOverride added in v2.2.4

func NewOverride(overrideHandler slog.Handler) CmdLogger

type Handler added in v2.0.2

type Handler struct {
	// contains filtered or unexported fields
}

func (*Handler) Enabled added in v2.0.2

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

func (*Handler) Handle added in v2.0.2

func (c *Handler) Handle(ctx 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) HasErroredBecauseInvalidConfig added in v2.1.0

func (c *Handler) HasErroredBecauseInvalidConfig() bool

HasErroredBecauseInvalidConfig returns true if there have been any calls to Handle with a level of slog.LevelError due to a config file being invalid

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) SetHasErrored added in v2.3.0

func (c *Handler) SetHasErrored()

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(a []slog.Attr) slog.Handler

func (*Handler) WithGroup added in v2.0.2

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

type ScalibrAdapter added in v2.2.4

type ScalibrAdapter struct {
	Logger *slog.Logger
}

func (*ScalibrAdapter) Debug added in v2.2.4

func (s *ScalibrAdapter) Debug(args ...any)

func (*ScalibrAdapter) Debugf added in v2.2.4

func (s *ScalibrAdapter) Debugf(format string, args ...any)

func (*ScalibrAdapter) Error added in v2.2.4

func (s *ScalibrAdapter) Error(args ...any)

func (*ScalibrAdapter) Errorf added in v2.2.4

func (s *ScalibrAdapter) Errorf(format string, args ...any)

func (*ScalibrAdapter) Info added in v2.2.4

func (s *ScalibrAdapter) Info(args ...any)

func (*ScalibrAdapter) Infof added in v2.2.4

func (s *ScalibrAdapter) Infof(format string, args ...any)

func (*ScalibrAdapter) Warn added in v2.2.4

func (s *ScalibrAdapter) Warn(args ...any)

func (*ScalibrAdapter) Warnf added in v2.2.4

func (s *ScalibrAdapter) Warnf(format string, args ...any)

Jump to

Keyboard shortcuts

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