log

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package log implements API-related logging helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnabledResponse

func EnabledResponse(rw http.ResponseWriter, r *http.Request, v any)

EnabledResponse log the response object if it implements the EnableLogger interface.

func Error

func Error(w http.ResponseWriter, r *http.Request, err error)

Error adds to the response writer the given error if it implements logging.ResponseLogger. If it does not implement it, then writes the error using the log package.

func WithErrorLogger added in v0.26.2

func WithErrorLogger(ctx context.Context, fn ErrorLogger) context.Context

WithErrorLogger returns a new context with the given error logger.

Types

type ErrorLogger added in v0.26.2

type ErrorLogger func(http.ResponseWriter, *http.Request, error)

ErrorLogger is the function type used to log errors.

func ErrorLoggerFromContext added in v0.26.2

func ErrorLoggerFromContext(ctx context.Context) (fn ErrorLogger)

ErrorLoggerFromContext returns an error logger from the context.

type StackTracedError

type StackTracedError interface {
	error

	StackTrace() errors.StackTrace
}

StackTracedError is the set of errors implementing the StackTrace function.

Errors implementing this interface have their stack traces logged when passed to the Error function of this package.

Jump to

Keyboard shortcuts

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