accesslog

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package accesslog records bounded, classified HTTP events to server-owned files.

Index

Constants

View Source
const MiB int64 = 1 << 20

Variables

This section is empty.

Functions

func LogicalBytes

func LogicalBytes(r *http.Request, n int)

LogicalBytes marks gzip input; the outer compressed write must not count twice.

func Method

func Method(method string) string

func NormalizeProxies

func NormalizeProxies(prefixes []netip.Prefix) ([]netip.Prefix, error)

NormalizeProxies preserves the legacy scheme policy; this set is address-only.

func RequestPanic

func RequestPanic(ctx context.Context, v any)

RequestPanic couples a handled MCP panic to the eventual access event. When logging is off the existing diagnostic boundary remains independently active.

Types

type Address

type Address struct {
	Peer, Client, Source string
	Ignored              bool
}

func ClientAddress

func ClientAddress(r *http.Request, opt bool, prefixes []netip.Prefix) Address

type Config

type Config struct {
	File                       string
	MaxSizeMiB                 int64
	MaxFiles, MaxAgeDays       int
	ForwardedFor, RetentionSet bool
}

func Defaults

func Defaults() Config

func (Config) Validate

func (c Config) Validate() error

type Counters

type Counters struct {
	Dropped        uint64 `json:"dropped_total,omitempty"`
	WriteErrors    uint64 `json:"write_errors_total,omitempty"`
	RotationErrors uint64 `json:"rotation_errors_total,omitempty"`
	PruneErrors    uint64 `json:"prune_errors_total,omitempty"`
	Reopens        uint64 `json:"reopens_total,omitempty"`
}

type InitError

type InitError struct{ Reason string }

func (*InitError) Error

func (e *InitError) Error() string

type Logger

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

func Open

func Open(dataDir string, c Config) (*Logger, error)

func (*Logger) Close

func (l *Logger) Close(ctx context.Context)

Close never closes the producer channel and never waits beyond the shared file/stderr drain deadline. A stuck OS write can outlive this deadline.

func (*Logger) Handler

func (l *Logger) Handler(next http.Handler, metadata func(*http.Request) Metadata) http.Handler

func (*Logger) Stats

func (l *Logger) Stats() Counters

func (*Logger) Submit

func (l *Logger) Submit(record Record)

type Metadata

type Metadata struct {
	Route   string
	Address Address
	TLS     bool
}

type Record

type Record struct {
	Type             string `json:"type"`
	Time             string `json:"time,omitempty"`
	Method           string `json:"method,omitempty"`
	Route            string `json:"route,omitempty"`
	PathLen          *int   `json:"path_len,omitempty"`
	Status           int    `json:"status"`
	DurationMS       int64  `json:"duration_ms"`
	Bytes            int64  `json:"bytes"`
	Client           string `json:"client,omitempty"`
	ClientSource     string `json:"client_source,omitempty"`
	Peer             string `json:"peer,omitempty"`
	TLS              bool   `json:"tls"`
	ForwardedIgnored bool   `json:"forwarded_ignored,omitempty"`
	Aborted          bool   `json:"aborted,omitempty"`
	Panic            bool   `json:"panic,omitempty"`
	ProcessStartedAt string `json:"process_started_at"`
	Counters
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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