Help us shape the future of Go! Take the 2026 Go Developer Survey

logger

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelTrace = slog.Level(-8)
	LevelDebug = slog.LevelDebug
	LevelInfo  = slog.LevelInfo
	LevelWarn  = slog.LevelWarn
	LevelError = slog.LevelError
)

Variables

This section is empty.

Functions

func ReduceFunctionName

func ReduceFunctionName(function string) string

Function used to reduce a Function name (from logging)

Types

type Buffer

type Buffer []byte

Buffer is a byte buffer.

This implementation is adapted from the unexported type buffer in go/src/fmt/print.go.

func NewBuffer

func NewBuffer() *Buffer

func (*Buffer) Free

func (b *Buffer) Free()

func (*Buffer) Len

func (b *Buffer) Len() int

func (*Buffer) Reset

func (b *Buffer) Reset()

func (*Buffer) SetLen

func (b *Buffer) SetLen(n int)

func (*Buffer) String

func (b *Buffer) String() string

func (*Buffer) Write

func (b *Buffer) Write(p []byte) (int, error)

func (*Buffer) WriteByte

func (b *Buffer) WriteByte(c byte) error

func (*Buffer) WriteString

func (b *Buffer) WriteString(s string) (int, error)

type Handler

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

func NewHandler

func NewHandler(w io.Writer, opts *slog.HandlerOptions) *Handler

func (*Handler) Enabled

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

func (*Handler) Handle

func (this *Handler) Handle(_ context.Context, r slog.Record) error

func (*Handler) ReplaceAttr

func (this *Handler) ReplaceAttr() func(groups []string, a slog.Attr) slog.Attr

func (*Handler) WithAttrs

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

func (*Handler) WithGroup

func (this *Handler) WithGroup(name string) slog.Handler

type Logger

type Logger struct {
	*slog.Logger
	// contains filtered or unexported fields
}

func GetLogger

func GetLogger() *Logger

func (*Logger) AddSource

func (this *Logger) AddSource()

func (*Logger) Clone

func (this *Logger) Clone() *Logger

func (*Logger) GetHandlerOptions

func (this *Logger) GetHandlerOptions() *slog.HandlerOptions

func (Logger) New

func (this Logger) New() *Logger

func (*Logger) Printf

func (this *Logger) Printf(format string, v ...any)

func (*Logger) Reset

func (this *Logger) Reset()

func (*Logger) SetDefault

func (this *Logger) SetDefault()

func (*Logger) SetHandler

func (this *Logger) SetHandler(handlerFunc func(io.Writer, *slog.HandlerOptions) slog.Handler)

func (*Logger) SetLogLevel

func (this *Logger) SetLogLevel(level slog.Level)

func (*Logger) SetOutput

func (this *Logger) SetOutput(output io.Writer)

func (*Logger) Trace

func (this *Logger) Trace(msg string, args ...any)

func (*Logger) TraceContext

func (this *Logger) TraceContext(ctx context.Context, msg string, args ...any)

func (Logger) With

func (this Logger) With(args ...any) *Logger

func (Logger) WithGroup

func (this Logger) WithGroup(name string) *Logger

Jump to

Keyboard shortcuts

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