handler

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MtlogLevelToSlog

func MtlogLevelToSlog(level core.LogEventLevel) slog.Level

MtlogLevelToSlog converts mtlog levels to slog levels

Types

type LogrSink

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

LogrSink implements logr.LogSink backed by mtlog's logger

func NewLogrSink

func NewLogrSink(logger core.Logger) *LogrSink

NewLogrSink creates a new logr.LogSink that writes to the provided mtlog logger

func (*LogrSink) Enabled

func (s *LogrSink) Enabled(level int) bool

Enabled tests whether this LogSink is enabled at the given V-level

func (*LogrSink) Error

func (s *LogrSink) Error(err error, msg string, keysAndValues ...interface{})

Error logs an error message with the given key/value pairs

func (*LogrSink) Info

func (s *LogrSink) Info(level int, msg string, keysAndValues ...interface{})

Info logs a non-error message with the given key/value pairs

func (*LogrSink) Init

func (s *LogrSink) Init(info logr.RuntimeInfo)

Init receives optional information about the logr library

func (*LogrSink) WithName

func (s *LogrSink) WithName(name string) logr.LogSink

WithName returns a new LogSink with the specified name appended

func (*LogrSink) WithValues

func (s *LogrSink) WithValues(keysAndValues ...interface{}) logr.LogSink

WithValues returns a new LogSink with additional key/value pairs

type SlogHandler

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

SlogHandler implements slog.Handler backed by mtlog's logger

func NewSlogHandler

func NewSlogHandler(logger core.Logger) *SlogHandler

NewSlogHandler creates a new slog.Handler that writes to the provided mtlog logger

func (*SlogHandler) Enabled

func (h *SlogHandler) Enabled(_ context.Context, level slog.Level) bool

Enabled reports whether the handler handles records at the given level

func (*SlogHandler) Handle

func (h *SlogHandler) Handle(ctx context.Context, record slog.Record) error

Handle handles the Record

func (*SlogHandler) WithAttrs

func (h *SlogHandler) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs returns a new Handler whose attributes consist of both the receiver's attributes and the arguments

func (*SlogHandler) WithGroup

func (h *SlogHandler) WithGroup(name string) slog.Handler

WithGroup returns a new Handler with the given group appended to the receiver's existing groups

Jump to

Keyboard shortcuts

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