log

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2024 License: MIT Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultLogger

func DefaultLogger() *slog.Logger

func New

func New(options ...HandlerWrapOption) *slog.Logger

New is wrapped constructor of log.slog

Types

type BlogAPILogHandler

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

BlogAPILogHandler is an implementation of slog.Handler for blogapi.

func NewBlogAPILogHandler

func NewBlogAPILogHandler(w io.Writer, handlerOption *slog.HandlerOptions) *BlogAPILogHandler

NewBlogAPILogHandler is constructor of BlogAPILogHandler.

func (*BlogAPILogHandler) Enabled

func (h *BlogAPILogHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*BlogAPILogHandler) Handle

func (h *BlogAPILogHandler) Handle(ctx context.Context, r slog.Record) error

Handle add trace id to slog.Attrs from context before output. See: https://pkg.go.dev/log/slog#JSONHandler.Handle

func (*BlogAPILogHandler) WithAttrs

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

func (*BlogAPILogHandler) WithGroup

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

type HandlerWrapOption

type HandlerWrapOption func(slog.Handler) slog.Handler

HandlerWrapOption is an option for slog.Handler.

func WithAltNRSlogTransactionalHandler

func WithAltNRSlogTransactionalHandler(app *newrelic.Application, nrtx *newrelic.Transaction) HandlerWrapOption

WithAltNRSlogTransactionalHandler returns a slog.Handler wrapped altnrslog,TransactionalHandler.

func WithInnerHandler

func WithInnerHandler(innerHandler slog.Handler) HandlerWrapOption

func WithWriter

func WithWriter(w io.Writer) HandlerWrapOption

WithWriter returns a slog.Handler with a modified log.writer if the handler type is BlogAPILogHandle otherwise unmodified slog.Handler.

type Logger

type Logger struct {
	*slog.Logger
}

type PreHandle

type PreHandle func(ctx context.Context, r *slog.Record) error

Jump to

Keyboard shortcuts

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