accesslog

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendSensitiveValues added in v0.1.4

func AppendSensitiveValues(base []string, values ...string) []string

func DefaultSensitiveHeaders added in v0.1.4

func DefaultSensitiveHeaders() []string

func FilterHeaders

func FilterHeaders(h http.Header) string

FilterHeaders filters sensitive request headers and returns a JSON string.

func FilterHeadersWithAdditionalSensitiveHeaders

func FilterHeadersWithAdditionalSensitiveHeaders(h http.Header, headers ...string) string

FilterHeadersWithAdditionalSensitiveHeaders filters default sensitive headers plus custom headers.

func FilterHeadersWithList added in v0.1.4

func FilterHeadersWithList(h http.Header, sensitiveHeaders []string) string

func FilterHeadersWithSensitiveHeaders

func FilterHeadersWithSensitiveHeaders(h http.Header, headers ...string) string

FilterHeadersWithSensitiveHeaders filters the specified sensitive headers.

func NormalizeSensitiveValues added in v0.1.4

func NormalizeSensitiveValues(values ...string) []string

func ResponseMeta added in v0.1.4

func ResponseMeta(body []byte) (int, string)

Types

type Actor

type Actor struct {
	ID   string
	Type string
	Name string
}

type Config

type Config struct {
	QueueSize     int
	BatchSize     int
	FlushInterval time.Duration
}

type Entry

type Entry struct {
	Source     string
	TrackID    string
	TraceID    string
	RequestID  string
	UID        string
	Method     string
	Path       string
	Query      string
	IP         string
	UserAgent  string
	Headers    []byte
	ReqBody    []byte
	StatusCode int
	ErrCode    int
	ErrMsg     string
	RespBody   []byte
	Latency    int64
	CreatedAt  int64
}

Entry is a generic HTTP access log record. It intentionally has no dependency on any concrete database model.

type Logger

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

Logger asynchronously buffers access log entries and writes them in batches.

func NewLogger

func NewLogger(writer Writer, cfg Config) *Logger

func (*Logger) Push

func (l *Logger) Push(entry *Entry)

Push enqueues an entry without blocking the request path. If the queue is full, the entry is dropped.

func (*Logger) Start

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

Start consumes queued entries until ctx is done, then flushes remaining logs.

type Writer

type Writer interface {
	WriteBatch(ctx context.Context, entries []*Entry) error
}

Writer persists access log entries in batches.

Jump to

Keyboard shortcuts

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