logging

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsStdLogger

func AsStdLogger(slogger *slog.Logger) *log.Logger

AsStdLogger creates a new log.Logger that uses the SlogAdapter to log messages.

func FromCtx

func FromCtx(ctx context.Context) *slog.Logger

func NewLogger

func NewLogger(w io.Writer, cfg *config.Config) *slog.Logger

func WithLogger

func WithLogger(ctx context.Context, l *slog.Logger) context.Context

Types

type NoOpHandler

type NoOpHandler struct{}

func NewNoOpHandler

func NewNoOpHandler() *NoOpHandler

func (*NoOpHandler) Enabled

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

func (*NoOpHandler) Handle

func (h *NoOpHandler) Handle(_ context.Context, _ slog.Record) error

func (*NoOpHandler) WithAttrs

func (h *NoOpHandler) WithAttrs(_ []slog.Attr) slog.Handler

func (*NoOpHandler) WithGroup

func (h *NoOpHandler) WithGroup(_ string) slog.Handler

type SlogAdapter

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

Define the SlogAdapter struct that wraps the slog.Logger.

func (SlogAdapter) Write

func (adapter SlogAdapter) Write(p []byte) (n int, err error)

Write implements the io.Writer interface required by log.Logger This method will be called whenever log.Logger's Print functions are called.

Jump to

Keyboard shortcuts

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