Documentation
¶
Overview ¶
Package cmdlogger provides wrapper for slog logging commands.
Index ¶
- Variables
- func Debugf(msg string, args ...any)
- func Errorf(msg string, args ...any)
- func HasErrored() bool
- func Infof(msg string, args ...any)
- func Levels() []string
- func ParseLevel(text string) (slog.Level, error)
- func SendEverythingToStderr()
- func SetLevel(level slog.Leveler)
- func Warnf(msg string, args ...any)
- type CmdLogger
- type Handler
- func (c *Handler) Enabled(ctx context.Context, level slog.Level) bool
- func (c *Handler) Handle(ctx context.Context, record slog.Record) error
- func (c *Handler) HasErrored() bool
- func (c *Handler) HasErroredBecauseInvalidConfig() bool
- func (c *Handler) SendEverythingToStderr()
- func (c *Handler) SetLevel(level slog.Leveler)
- func (c *Handler) WithAttrs(a []slog.Attr) slog.Handler
- func (c *Handler) WithGroup(g string) slog.Handler
Constants ¶
This section is empty.
Variables ¶
var GlobalHandler slog.Handler
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 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.
Types ¶
type CmdLogger ¶
type Handler ¶ added in v2.0.2
func (*Handler) HasErrored ¶ added in v2.0.2
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
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.