Documentation
¶
Index ¶
- Constants
- Variables
- func ParseLogTime(line []byte) (t time.Time)
- type AccessLogIO
- type AccessLogger
- type BackScanner
- type CIDR
- type CombinedFormatter
- type CommonFormatter
- type Config
- type FieldConfig
- type FieldMode
- type Fields
- type File
- type Filterable
- type Filters
- type Format
- type Formatter
- type HTTPHeader
- type HTTPMethod
- type Host
- type JSONFormatter
- type JSONLogEntry
- type LogFilter
- type MockFile
- func (m *MockFile) Close() error
- func (m *MockFile) Content() []byte
- func (m *MockFile) Len() int64
- func (m *MockFile) LineCount() int
- func (m *MockFile) Name() string
- func (m *MockFile) Read(p []byte) (n int, err error)
- func (m *MockFile) ReadAt(p []byte, off int64) (n int, err error)
- func (m *MockFile) Seek(offset int64, whence int) (int64, error)
- func (m *MockFile) Truncate(size int64) error
- func (m *MockFile) Write(p []byte) (n int, err error)
- type Retention
- type StatusCodeRange
Constants ¶
View Source
const DefaultBufferSize = 64 * 1024 // 64KB
View Source
const LogTimeFormat = "02/Jan/2006:15:04:05 -0700"
Variables ¶
View Source
var ( ErrInvalidSyntax = gperr.New("invalid syntax") ErrZeroValue = gperr.New("zero value") )
View Source
var ErrInvalidHTTPHeaderFilter = gperr.New("invalid http header filter")
View Source
var ErrInvalidStatusCodeRange = gperr.New("invalid status code range")
Functions ¶
func ParseLogTime ¶
Types ¶
type AccessLogIO ¶
type AccessLogger ¶
type AccessLogger struct {
Formatter
// contains filtered or unexported fields
}
func NewAccessLogger ¶
func NewAccessLogger(parent task.Parent, io AccessLogIO, cfg *Config) *AccessLogger
func NewFileAccessLogger ¶
func NewFileAccessLogger(parent task.Parent, cfg *Config) (*AccessLogger, error)
func (*AccessLogger) Config ¶
func (l *AccessLogger) Config() *Config
func (*AccessLogger) Flush ¶
func (l *AccessLogger) Flush() error
func (*AccessLogger) Rotate ¶
func (l *AccessLogger) Rotate() error
type BackScanner ¶
type BackScanner struct {
// contains filtered or unexported fields
}
BackScanner provides an interface to read a file backward line by line.
func NewBackScanner ¶
func NewBackScanner(file AccessLogIO, chunkSize int) *BackScanner
NewBackScanner creates a new Scanner to read the file backward. chunkSize determines the size of each read chunk from the end of the file.
func (*BackScanner) Bytes ¶
func (s *BackScanner) Bytes() []byte
Bytes returns the most recent line generated by a call to Scan.
func (*BackScanner) Err ¶
func (s *BackScanner) Err() error
Err returns the first non-EOF error encountered by the scanner.
func (*BackScanner) FileSize ¶
func (s *BackScanner) FileSize() int64
FileSize returns the size of the file.
func (*BackScanner) Scan ¶
func (s *BackScanner) Scan() bool
Scan advances the scanner to the previous line, which will then be available via the Bytes method. It returns false when there are no more lines.
type CombinedFormatter ¶
type CombinedFormatter struct{ CommonFormatter }
type CommonFormatter ¶
type CommonFormatter struct {
GetTimeNow func() time.Time // for testing purposes only
// contains filtered or unexported fields
}
func (*CommonFormatter) SetGetTimeNow ¶
func (f *CommonFormatter) SetGetTimeNow(getTimeNow func() time.Time)
debug only.
type Config ¶
type Config struct {
BufferSize int `json:"buffer_size"`
Format Format `json:"format" validate:"oneof=common combined json"`
Path string `json:"path" validate:"required"`
Filters Filters `json:"filters"`
Fields Fields `json:"fields"`
Retention *Retention `json:"retention"`
}
func DefaultConfig ¶
func DefaultConfig() *Config
type FieldConfig ¶
type FieldConfig struct {
Default FieldMode `json:"default" validate:"oneof=keep drop redact"`
Config map[string]FieldMode `json:"config" validate:"dive,oneof=keep drop redact"`
}
func (*FieldConfig) ProcessCookies ¶
func (cfg *FieldConfig) ProcessCookies(cookies []*http.Cookie) map[string]string
func (*FieldConfig) ProcessHeaders ¶
func (cfg *FieldConfig) ProcessHeaders(headers http.Header) http.Header
func (*FieldConfig) ProcessQuery ¶
func (cfg *FieldConfig) ProcessQuery(q url.Values) url.Values
type Fields ¶
type Fields struct {
Headers FieldConfig `json:"headers"`
Query FieldConfig `json:"query"`
Cookies FieldConfig `json:"cookies"`
}
type Filterable ¶
type HTTPMethod ¶
type HTTPMethod string
type JSONFormatter ¶
type JSONFormatter struct{ CommonFormatter }
type JSONLogEntry ¶
type JSONLogEntry struct {
Time string `json:"time"`
IP string `json:"ip"`
Method string `json:"method"`
Scheme string `json:"scheme"`
Host string `json:"host"`
URI string `json:"uri"`
Protocol string `json:"protocol"`
Status int `json:"status"`
Error string `json:"error,omitempty"`
ContentType string `json:"type"`
Size int64 `json:"size"`
Referer string `json:"referer"`
UserAgent string `json:"useragent"`
Query map[string][]string `json:"query,omitempty"`
Headers map[string][]string `json:"headers,omitempty"`
Cookies map[string]string `json:"cookies,omitempty"`
}
type StatusCodeRange ¶
func (*StatusCodeRange) Includes ¶
func (r *StatusCodeRange) Includes(code int) bool
func (*StatusCodeRange) Parse ¶
func (r *StatusCodeRange) Parse(v string) error
Parse implements strutils.Parser.
func (*StatusCodeRange) String ¶
func (r *StatusCodeRange) String() string
Click to show internal directories.
Click to hide internal directories.