accesslog

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMiddleware

func NewMiddleware(logger AccessLogger) func(http.Handler) http.Handler

Types

type AccessLogger

type AccessLogger interface {
	Log(ctx context.Context, entry *Entry)
}

func NewAccessLogger

func NewAccessLogger(name string, opts Options) (AccessLogger, error)

type Entry

type Entry struct {
	Username string
	Latency  time.Duration
	ClientIP string
	Request  Request
	Response Response
}

func NewEntry

func NewEntry(r *http.Request) *Entry

func (*Entry) MarshalZerologObject

func (m *Entry) MarshalZerologObject(e *zerolog.Event)

func (*Entry) String

func (m *Entry) String(e *zerolog.Event) string

type JsonLogger

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

func NewJsonLogger

func NewJsonLogger(name string, writer io.Writer) *JsonLogger

func (*JsonLogger) Log

func (l *JsonLogger) Log(ctx context.Context, entry *Entry)

type Options

type Options struct {
	File    string
	Format  string
	Colored bool
}

type Request

type Request struct {
	Method  string
	Path    string
	Proto   string
	Headers map[string]string
}

type Response

type Response struct {
	Status int
	Size   int
}

type TextLogger

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

func NewTextLogger

func NewTextLogger(name string, writer io.Writer, colored bool) *TextLogger

func (*TextLogger) Log

func (l *TextLogger) Log(ctx context.Context, entry *Entry)

Jump to

Keyboard shortcuts

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