logging

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AccessLogCookiesBlacklist []string

The of cookies which should not be logged

View Source
var AccessLogWithCookies = true
View Source
var AnonymizedQueryParams []string

List of query params that should be anonymized

View Source
var CorrelationIdHeader = "X-Correlation-Id"
View Source
var LifecycleEnvVars = []string{"BUILD_NUMBER", "BUILD_HASH", "BUILD_DATE"}
View Source
var Logger *logrus.Entry
View Source
var UserCorrelationIdHeader = "X-User-Correlation-Id"

Functions

func Access

func Access(r *http.Request, start time.Time, statusCode int)

Access logs an access entry with call duration and status code

func AccessError

func AccessError(r *http.Request, start time.Time, err error)

AccessError logs an error while accessing

func Application

func Application(h http.Header) *logrus.Entry

Return a log entry for application logs, pre-filled with the correlation ids out of the supplied request.

func Cacheinfo

func Cacheinfo(url string, hit bool)

Cacheinfo logs the hit information a accessing a ressource

func Call

func Call(r *http.Request, resp *http.Response, start time.Time, err error)

Call logs the result of an outgoing call

func EnsureCorrelationId

func EnsureCorrelationId(r *http.Request) string

EnsureCorrelationId returns the correlation from of the request. If the request does not have a correlation id, one will be generated and set to the request.

func GetCorrelationId

func GetCorrelationId(h http.Header) string

GetCorrelationId returns the correlation from of the request.

func GetUserCorrelationId

func GetUserCorrelationId(h http.Header) string

GetCorrelationId returns the correlation from of the request.

func LifecycleStart

func LifecycleStart(appName string, args interface{})

LifecycleStart logs the start of an application with the configuration struct or map as paramter.

func LifecycleStop

func LifecycleStop(appName string, signal os.Signal, err error)

LifecycleStop logs the stop of an application

func Set

func Set(level string, textLogging bool) error

Set creates a new Logger with the matching specification

Types

type LogMiddleware

type LogMiddleware struct {
	Next http.Handler
	// contains filtered or unexported fields
}

func NewLogMiddleware

func NewLogMiddleware(next http.Handler, options ...LogOption) *LogMiddleware

NewLogMiddleware returns a new log handler wrapping a given handler. Further configuration can be done by passing relevant option functions.

func (*LogMiddleware) ServeHTTP

func (mw *LogMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)

type LogOption

type LogOption func(*LogMiddleware)

func WithPanicStatus

func WithPanicStatus(statusCode int) LogOption

WithPanicStatus modifies the middleware so that it reponds with a given statuscode if a panic occurs. Respectively not setting this will not modify the response code in any way.

Jump to

Keyboard shortcuts

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