zaphelper

package
v0.0.0-...-08b4e76 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package zaphelpers provides several helpers for the usage with zap.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) *zap.Logger

FromContext extracts a logger from the context, if it's injected there. Otherwise, a no-op logger is returned.

func FromRequest

func FromRequest(r *http.Request) *zap.Logger

FromRequest extracts a logger from the current request context, if it's injected there. Otherwise, a no-op logger is returned.

Types

type HTTPMiddleware

type HTTPMiddleware func(handler http.Handler) http.Handler

HTTPMiddleware defines the type for the usual net/http middleware.

func InjectLogger

func InjectLogger(logger *zap.Logger) HTTPMiddleware

InjectLogger returns a middleware that injects the given logger into each request.

func RequestLogger

func RequestLogger() HTTPMiddleware

RequestLogger logs each HTTP request. It should be added to the middleware stack after InjectLogger.

Jump to

Keyboard shortcuts

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