log

package
v1.8.25 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: GPL-3.0 Imports: 16 Imported by: 11

Documentation

Index

Constants

View Source
const RequestIDKey ctxKeyRequestID = 0

RequestIDKey is the key that holds the unique request ID in a request context.

Variables

View Source
var (
	Logger *zap.Logger
)
View Source
var RequestIDHeader = "X-Request-Id"

RequestIDHeader is the name of the HTTP Header which contains the request id. Exported so that it can be changed by developers

Functions

func DecodeBody

func DecodeBody(r io.ReadCloser) zap.Field

func DecodeBodyFromRequest

func DecodeBodyFromRequest(r *http.Request) zap.Field

func DecodeBodyFromResponse

func DecodeBodyFromResponse(r *http.Response) zap.Field

func DecodeHeader

func DecodeHeader(h http.Header) zap.Field

func DecodeHeaderFromRequest

func DecodeHeaderFromRequest(r *http.Request) zap.Field

func DecodeHeaderFromResponse

func DecodeHeaderFromResponse(r *http.Response) zap.Field

func GetNextRequestID

func GetNextRequestID() string

func GetReqID

func GetReqID(ctx context.Context) string

GetReqID returns a request ID from the given context if one is present. Returns the empty string if a request ID cannot be found.

func Level

func Level(level string) zapcore.Level

func LoggerFromReqID added in v1.7.19

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

Types

type Config

type Config struct {
	LogLevel string `split_words:"true" default:"info"`
}

Jump to

Keyboard shortcuts

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