Documentation
¶
Index ¶
- func Err(err error) slog.Attr
- func NewWebhookLogger(cfg api.SystemSettingsLog) (slog.Handler, error)
- func ParseLevel(levelStr string) slog.Level
- func SlogBackedLogrus() *logrus.Logger
- func ValidateLevel(levelStr string) error
- func WebhookConfigChanged(oldCfgs, newCfgs []api.SystemSettingsLog) bool
- func WebhookDefaultConfig(cfg api.SystemSettingsLog) api.SystemSettingsLog
- func WebhookValidateConfig(cfg api.SystemSettingsLog) error
- type Handler
- func (h *Handler) AddHandler(handler slog.Handler)
- func (h *Handler) Enabled(ctx context.Context, lvl slog.Level) bool
- func (h *Handler) Handle(ctx context.Context, rec slog.Record) error
- func (h *Handler) SendLifecycle(ctx context.Context, event api.EventLifecycle)
- func (h *Handler) SetHandlers(cfgs []api.SystemSettingsLog) error
- func (h *Handler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *Handler) WithGroup(name string) slog.Handler
- type Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Err ¶
Err is a helper function to ensure errors are always logged with the key "err". Additionally this becomes the single point in code, where we could tweak how errors are logged, e.g. to handle application specific error types or to add stack trace information in debug mode.
func NewWebhookLogger ¶ added in v0.2.0
func NewWebhookLogger(cfg api.SystemSettingsLog) (slog.Handler, error)
func ParseLevel ¶ added in v0.2.0
func SlogBackedLogrus ¶
func ValidateLevel ¶ added in v0.2.0
func WebhookConfigChanged ¶ added in v0.2.0
func WebhookConfigChanged(oldCfgs, newCfgs []api.SystemSettingsLog) bool
func WebhookDefaultConfig ¶ added in v0.2.0
func WebhookDefaultConfig(cfg api.SystemSettingsLog) api.SystemSettingsLog
func WebhookValidateConfig ¶ added in v0.2.0
func WebhookValidateConfig(cfg api.SystemSettingsLog) error
Types ¶
type Handler ¶ added in v0.2.0
func NewLogHandler ¶ added in v0.2.0
func NewLogHandler(level slog.Level, options slog.HandlerOptions) *Handler
NewLogHandler creates a new log handler with the given default options, level, and sub-handlers.
func (*Handler) AddHandler ¶ added in v0.2.0
func (*Handler) Enabled ¶ added in v0.2.0
Enabled returns true if any logger is enabled for the level.
func (*Handler) Handle ¶ added in v0.2.0
Handle calls Handle for all handlers for which log level is enabled. Errors will be collected and returned together.
func (*Handler) SendLifecycle ¶ added in v0.2.0
func (h *Handler) SendLifecycle(ctx context.Context, event api.EventLifecycle)
func (*Handler) SetHandlers ¶ added in v0.2.0
func (h *Handler) SetHandlers(cfgs []api.SystemSettingsLog) error
SetHandlers replaces the log handler set with additional config-based handlers, keeping any default handlers.
type Logger ¶
type Logger interface {
Debug(msg string, args ...any)
DebugContext(ctx context.Context, msg string, args ...any)
Error(msg string, args ...any)
ErrorContext(ctx context.Context, msg string, args ...any)
Info(msg string, args ...any)
InfoContext(ctx context.Context, msg string, args ...any)
Warn(msg string, args ...any)
WarnContext(ctx context.Context, msg string, args ...any)
With(args ...any) *slog.Logger
}