log

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TraceCtxKey contextKey = iota + 1
)

Variables

This section is empty.

Functions

func Closer

func Closer(ctx context.Context, c io.Closer)

Closer calls the Close method, if the closure occurred with an error, it prints out.

func DumpHttpRequest

func DumpHttpRequest(ctx context.Context, r *http.Request, level slog.Level)

DumpHttpRequest dumps the HTTP request and prints out.

func DumpHttpResponse

func DumpHttpResponse(ctx context.Context, r *http.Response, level slog.Level)

DumpHttpResponse dumps the HTTP response and prints out.

Types

type TraceHandler

type TraceHandler struct {
	slog.Handler
}

TraceHandler allows the slog to add a trace ID to logs from the context. To add a trace ID to the context, use TraceCtxKey:

ctx = context.WithValue(ctx, log.TraceCtxKey, 'put_trace_id_here')

func (TraceHandler) Handle

func (h TraceHandler) Handle(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