log

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger interface {
	// Debug will log at debug level.
	Debug(keyPairs ...any)

	// Info will log at info level.
	Info(keyPairs ...any)

	// Error will log at error level.
	Error(keyPairs ...any)
}

Logger exposes three different levels of logging.

The logger expects key-value pairs to enable structured logging.

Example:

log.Info("msg", "example log", "requestID", "1234")

type Option added in v0.19.0

type Option func(*Options)

Option is an option used to configure the retrieval of the Logger.

Example:

logger := api.Logger(WithFromRequest(req))

func WithRequest added in v0.19.0

func WithRequest(r *http.Request) Option

WithRequest retrieves the logger from the request's context. If no logger is found on the request's context or the request is nil, a default logger will be returned.

This method only needs be used in service extensions that expose their own HTTP handlers using router.HandleFunc. Using this request bound logger ensures request specific key-value pairs (e.g. traceID) are included in log messages.

type Options added in v0.19.0

type Options struct {
	Request *http.Request
}

Jump to

Keyboard shortcuts

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