alog

package
v0.0.0-...-aef14cd Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Unlicense Imports: 15 Imported by: 0

Documentation

Overview

Package alog кастомизация slog логгера.

Package alog кастомизация slog логгера.

Package alog кастомизация slog логгера.

Package alog кастомизация slog логгера.

Package alog кастомизация slog логгера.

Index

Constants

This section is empty.

Variables

View Source
var (
	TraceIDKey   = "trace-id"
	SpanIDKey    = "span-id"
	RequestIDKey = "requestId"

	RequestBodyMaxSize  = 64 * 1024 // 64KB
	ResponseBodyMaxSize = 64 * 1024 // 64KB

	HiddenRequestHeaders = map[string]struct{}{
		"authorization": {},
		"cookie":        {},
		"set-cookie":    {},
		"x-auth-token":  {},
		"x-csrf-token":  {},
		"x-xsrf-token":  {},
	}
	HiddenResponseHeaders = map[string]struct{}{
		"set-cookie": {},
	}

	// Formatted with http.CanonicalHeaderKey
	RequestIDHeaderKey = "X-Request-Id"
)

Functions

func GetLogger

func GetLogger() *slog.Logger

GetLogger получение логгера.

func New

func New(logger *slog.Logger) fiber.Handler

New returns a fiber.Handler (middleware) that logs requests using slog.

Requests with errors are logged using slog.Error(). Requests without errors are logged using slog.Info(). Исправленный. Оригинал: https://github.com/samber/slog-fiber

func NewLogger

func NewLogger(handler slog.Handler)

NewLogger потокобезопасное (thread-safe) создание логгера.

func NewWithConfig

func NewWithConfig(logger *slog.Logger, config Config) fiber.Handler

NewWithConfig returns a fiber.Handler (middleware) that logs requests using slog.

Types

type Config

type Config struct {
	DefaultLevel     slog.Level
	ClientErrorLevel slog.Level
	ServerErrorLevel slog.Level

	WithUserAgent      bool
	WithRequestID      bool
	WithRequestBody    bool
	WithRequestHeader  bool
	WithResponseBody   bool
	WithResponseHeader bool
	WithSpanID         bool
	WithTraceID        bool

	Filters []slogf.Filter
}

type HandlerJSON

type HandlerJSON struct {
	slog.Handler
	// contains filtered or unexported fields
}

HandlerJSON промышленный JSON логгер.

func NewHandlerJSON

func NewHandlerJSON(out io.Writer, opts *slog.HandlerOptions) *HandlerJSON

func (*HandlerJSON) Handle

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

Handle обработчик промышленного JSON логгера.

type PrettyHandler

type PrettyHandler struct {
	slog.Handler
	// contains filtered or unexported fields
}

PrettyHandler «симпатичный» логгер.

func NewPrettyHandlerText

func NewPrettyHandlerText(out io.Writer, opts PrettyHandlerOptions) *PrettyHandler

func (*PrettyHandler) Handle

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

Handle обработчик «симпатичный» логгера.

type PrettyHandlerOptions

type PrettyHandlerOptions struct {
	SlogOpts slog.HandlerOptions
}

Jump to

Keyboard shortcuts

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