httpfieldlogger

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

httpfieldlogger

Provides a middleware generating http access logs.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func M

func M(l Logger) func(next http.Handler) http.Handler

M returns a logger handler middleware.

func WithEvent

func WithEvent(r *http.Request, entry Event) *http.Request

WithEvent sets the in-context Event for a request.

Types

type Entry

type Entry struct {
	Logger logr.Logger
}

func (*Entry) Panic

func (e *Entry) Panic(v any)

func (*Entry) WithField

func (e *Entry) WithField(k string, v any) Event

func (*Entry) Write

func (e *Entry) Write(p harwp.ResponseWriterProxier, elapsed time.Duration)

type Event

type Event interface {
	WithField(k string, v any) Event
	Write(p harwp.ResponseWriterProxier, since time.Duration)
}

func GetEvent

func GetEvent(r *http.Request) Event

GetEvent returns the in-context Event for a request.

type FieldLogger

type FieldLogger struct {
	Logger logr.Logger
}

func New

func New(logger logr.Logger) *FieldLogger

func (*FieldLogger) NewLogEntry

func (l *FieldLogger) NewLogEntry(r *http.Request) Event

type Logger

type Logger interface {
	NewLogEntry(r *http.Request) Event
}

Jump to

Keyboard shortcuts

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