Help us shape the future of Go! Take the 2026 Go Developer Survey

logging

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package logging provides structured HTTP request logging middleware.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler logs each request after delegating it to the next handler.

func New

func New(next http.Handler, event string) *Handler

New constructs middleware that logs to the request context's logger. event names the SPECTRE event each request is logged under, e.g. "received".

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(writer http.ResponseWriter, request *http.Request)

ServeHTTP logs the event, method, path, response status, and elapsed time. Per-request logging is verbose, so it is emitted at debug level.

Jump to

Keyboard shortcuts

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