accesslog

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogTypeDebug = "debug"
	LogTypeInfo  = "info"
	LogTypeWarn  = "warn"
	LogTypeError = "error"
)

Variables

This section is empty.

Functions

func Log

func Log(levelType, message string, args ...any)

Types

type AccessLog

type AccessLog struct {
	Level   string `cfg:"level"`
	Message string `cfg:"message"`

	// SkipSSE disables access logging for SSE (text/event-stream) requests.
	// Default is true (SSE logging is skipped). Set to false to enable SSE logging.
	SkipSSE *bool `cfg:"skip_sse"`

	Path Path `cfg:"path"`

	LogDetails LogDetails `cfg:"log_details"`
}

func (*AccessLog) Middleware

func (m *AccessLog) Middleware() (func(http.Handler) http.Handler, error)

func (*AccessLog) TypeCheck

func (m *AccessLog) TypeCheck() error

type Check

type Check struct {
	URL string `cfg:"url"`
	// Method is the HTTP method to check for, default all methods "*"
	Methods []string `cfg:"methods"`

	LogDetails *LogDetails `cfg:"log_details"`
	// contains filtered or unexported fields
}

func (*Check) IsIn

func (c *Check) IsIn(path, method string) bool

type LogDetails

type LogDetails struct {
	// RequestBody is the request body to log default true
	RequestBody *bool `cfg:"request_body"`
	// RequestBodySize is the maximum size of the request body to log
	// default is 512 (bytes), 0 means no limit
	RequestBodySize int `cfg:"request_body_size"`
	// ResponseBody is the response body to log default true
	ResponseBody *bool `cfg:"response_body"`
	// ResponseBodySize is the maximum size of the response body to log
	// default is 512 (bytes), 0 means no limit
	ResponseBodySize int `cfg:"response_body_size"`
	// Headers is the headers to log default true
	Headers *bool `cfg:"headers"`
	// SanitizeHeaders is a list of headers to sanitize before logging.
	// Default added Authorization, Cookie, Set-Cookie
	// and X-Forwarded-For headers.
	// The headers will be sanitized to [REDACTED]
	SanitizeHeaders []string `cfg:"sanitize_headers"`
}

func (*LogDetails) Default

func (l *LogDetails) Default()

func (*LogDetails) GetHeaders

func (l *LogDetails) GetHeaders() bool

func (*LogDetails) GetRequestBody

func (l *LogDetails) GetRequestBody() bool

func (*LogDetails) GetResponseBody

func (l *LogDetails) GetResponseBody() bool

type Method

type Method struct {
	Blocked  []string `cfg:"blocked"`
	Allowed  []string `cfg:"allowed"`
	AllowAll bool     `cfg:"allow_all"`
}

func NewMethod

func NewMethod(methods []string) *Method

func (*Method) IsIn

func (r *Method) IsIn(method string) bool

type Path

type Path struct {
	Disabled []Check `cfg:"disabled"`
	Enabled  []Check `cfg:"enabled"`
}

Jump to

Keyboard shortcuts

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