apiserverk8s.io/apiserver/pkg/server/httplog Index | Files

package httplog

import "k8s.io/apiserver/pkg/server/httplog"

Package httplog contains a helper object and functions to maintain a log along with an http response.

Index

Functions

func DefaultStacktracePred

func DefaultStacktracePred(status int) bool

DefaultStacktracePred is the default implementation of StacktracePred.

func LogOf

func LogOf(req *http.Request, w http.ResponseWriter) logger

LogOf returns the logger hiding in w. If there is not an existing logger then a passthroughLogger will be created which will log to stdout immediately when Addf is called.

func NewLogged

func NewLogged(req *http.Request, w *http.ResponseWriter) *respLogger

NewLogged turns a normal response writer into a logged response writer.

Usage:

defer NewLogged(req, &w).StacktraceWhen(StatusIsNot(200, 202)).Log()

(Only the call to Log() is deferred, so you can set everything up in one line!)

Note that this *changes* your writer, to route response writing actions through the logger.

Use LogOf(w).Addf(...) to log something along with the response result.

func Unlogged

Unlogged returns the original ResponseWriter, or w if it is not our inserted logger.

Types

type StacktracePred

type StacktracePred func(httpStatus int) (logStacktrace bool)

StacktracePred returns true if a stacktrace should be logged for this status.

func StatusIsNot

func StatusIsNot(statuses ...int) StacktracePred

StatusIsNot returns a StacktracePred which will cause stacktraces to be logged for any status *not* in the given list.

Source Files

doc.go httplog.go

Version
v0.15.12-beta.0
Published
Mar 13, 2020
Platform
js/wasm
Imports
7 packages
Last checked
4 minutes ago

Tools for package owners.