accesslog

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2025 License: Apache-2.0 Imports: 9 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(entry *Entry)
}

func NewAccessLogger

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

type Entry

type Entry struct {
	Username string        `json:"username"`
	Latency  time.Duration `json:"latency"`
	ClientIP string        `json:"client_ip"`

	Request  Request  `json:"request"`
	Response Response `json:"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() 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(entry *Entry)

type Options

type Options struct {
	File   string
	Format string
}

type Request

type Request struct {
	Method  string            `json:"method"`
	Path    string            `json:"path"`
	Proto   string            `json:"proto"`
	Headers map[string]string `json:"headers"`
}

type Response

type Response struct {
	Status int `json:"status"`
	Size   int `json:"size"`
}

type TextLogger

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

func NewTextLogger

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

func (*TextLogger) Log

func (l *TextLogger) Log(entry *Entry)

Jump to

Keyboard shortcuts

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