accesslog

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessLog

type AccessLog struct {
	// Old format (for backward compatibility)
	Level   string  `json:"level"`
	Ts      float64 `json:"ts"`
	Logger  string  `json:"logger"`
	Msg     string  `json:"msg"`
	Request struct {
		RemoteIP   string              `json:"remote_ip"`
		RemotePort string              `json:"remote_port"`
		Proto      string              `json:"proto"`
		Method     string              `json:"method"`
		Host       string              `json:"host"`
		URI        string              `json:"uri"`
		Headers    map[string][]string `json:"headers"`
	} `json:"request"`
	UserID      string  `json:"user_id"`
	Duration    float64 `json:"duration"`
	Size        int     `json:"size"`
	Status      int     `json:"status"`
	RespHeaders struct {
		ContentType []string `json:"Content-Type"`
		Server      []string `json:"Server"`
	} `json:"resp_headers"`

	// New Traefik format (Swarm mode)
	ClientAddr            string `json:"ClientAddr"`
	ClientHost            string `json:"ClientHost"`
	DownstreamStatus      int    `json:"DownstreamStatus"`
	RequestMethod         string `json:"RequestMethod"`
	RequestPath           string `json:"RequestPath"`
	RequestProtocol       string `json:"RequestProtocol"`
	RequestHost           string `json:"RequestHost"`
	ServiceName           string `json:"ServiceName"`
	OriginDuration        int64  `json:"OriginDuration"` // nanoseconds
	OriginContentSize     int64  `json:"OriginContentSize"`
	Time                  string `json:"time"`
	DownstreamContentSize int64  `json:"DownstreamContentSize"`
}

AccessLog represents a JSON access log entry (Traefik format)

type Formatter

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

Formatter handles formatting of access logs

func NewFormatter

func NewFormatter(verbose bool) *Formatter

NewFormatter creates a new log formatter

func (*Formatter) FormatHeader

func (f *Formatter) FormatHeader() string

FormatHeader returns a formatted header for the log output

func (*Formatter) FormatLine

func (f *Formatter) FormatLine(line string) (string, error)

FormatLine formats a single JSON log line into human-readable output

func (*Formatter) SetServiceFilter

func (f *Formatter) SetServiceFilter(serviceName string)

SetServiceFilter sets a filter to only show logs for a specific service

Jump to

Keyboard shortcuts

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