logger

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) zerolog.Logger

FromContext retrieves logger from context or returns global logger.

func GetRequestID

func GetRequestID(ctx context.Context) string

GetRequestID retrieves request ID from context.

func Middleware

func Middleware(logger zerolog.Logger) func(http.Handler) http.Handler

Middleware creates HTTP middleware that injects request logger into context. It generates a unique request ID and adds it to both context and response headers.

func New

func New(cfg Config) zerolog.Logger

New creates a new global logger with default configuration.

func RedactEmail

func RedactEmail(email string) string

RedactEmail masks email for PII compliance (keep domain for analytics).

func TruncateAddress

func TruncateAddress(addr string) string

TruncateAddress truncates wallet/signature for privacy (show first 8 + last 4 chars).

func WithContext

func WithContext(ctx context.Context, logger zerolog.Logger) context.Context

WithContext adds logger to context for retrieval in handlers.

func WithRequestID

func WithRequestID(ctx context.Context, requestID string) context.Context

WithRequestID adds request ID to context for tracing.

Types

type Config

type Config struct {
	Level       string // debug, info, warn, error
	Format      string // json, console
	Service     string
	Version     string
	Environment string
}

Config holds logger configuration.

Jump to

Keyboard shortcuts

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