logging

package
v0.0.0-...-e0dfdda Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: MIT Imports: 10 Imported by: 29

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

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

FromContext returns a logger stored in a context.

func Handler

func Handler(logger *zap.Logger, projectID string) func(next http.Handler) http.Handler

Handler does the actual work of the http middleware.

func Middleware

func Middleware(log *zap.Logger, projectID string) func(next http.Handler) http.Handler

Middleware is a middleware for writing request logs in a structured format to stackdriver. It uses a chi Chain to make sure all of the deps are properly included (RequestID and Recoverer).

func Must

func Must(log *zap.SugaredLogger, err error) *zap.SugaredLogger

Must panics if the logger can not be created.

func NewContext

func NewContext(ctx context.Context, logger *zap.SugaredLogger, fields ...interface{}) context.Context

NewContext wraps a context with a logger with default fields.

func NewLogger

func NewLogger(serviceName string) (*zap.SugaredLogger, error)

NewLogger creates a logger with stackdriver settings.

func ParseTraceHeader

func ParseTraceHeader(header string) (string, string, bool)

ParseTraceHeader takes a GCP trace header and translates it to a trace, span, and whether or not this was sampled.

Types

This section is empty.

Jump to

Keyboard shortcuts

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