v2zgo.at/goatcounter/v2/logscan Index | Files

package logscan

import "zgo.at/goatcounter/v2/logscan"

Index

Constants

const (
	// Combined format; used by default in Apache, nginx.
	//
	// 127.0.0.1    user -  [10/Oct/2000:13:55:36 -0700] "GET     /path HTTP/1.1" 200     2326  "https://ref" "Mozilla/5.0"
	// $remote_addr $ignore [$datetime]                  "$method $path $http"    $status $size "$referrer"   "$user_agent"
	Combined      = `$remote_addr $ignore [$datetime] "$method $path $http" $status $size "$referrer" "$user_agent"`
	CombinedVhost = `$host:` + Combined

	// Common log format.
	//
	// 127.0.0.1    user -  [10/Oct/2000:13:55:36 -0700] "GET     /path HTTP/1.1" 200     2326
	// $remote_addr $ignore [$datetime]                  "$method $path $http"    $status $size`
	Common      = `$remote_addr $ignore [$datetime] "$method $path $http" $status $size`
	CommonVhost = `$host:` + Common
)

Types

type Line

type Line map[string]string

func (Line) ContentType

func (l Line) ContentType() string

func (Line) Datetime

func (l Line) Datetime(scan *Scanner) (time.Time, error)

func (Line) HTTP

func (l Line) HTTP() string

func (Line) Host

func (l Line) Host() string

func (Line) Line

func (l Line) Line() string

func (Line) LineNo

func (l Line) LineNo() uint64

func (Line) Method

func (l Line) Method() string

func (Line) Path

func (l Line) Path() string

func (Line) Query

func (l Line) Query() string

func (Line) Referrer

func (l Line) Referrer() string

func (Line) RemoteAddr

func (l Line) RemoteAddr() string

func (Line) Size

func (l Line) Size() int

func (Line) Status

func (l Line) Status() int

func (Line) Timing

func (l Line) Timing() time.Duration

func (Line) UserAgent

func (l Line) UserAgent() string

func (Line) XForwardedFor

func (l Line) XForwardedFor() string

type Scanner

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

func New

func New(in io.Reader, format, date, tyme, datetime string, exclude []string) (*Scanner, error)

New processes all the lines in the reader.

func NewFollow

func NewFollow(ctx context.Context, file, format, date, tyme, datetime string, exclude []string) (*Scanner, error)

NewFollow follows a file for new lines and processes them. Existing lines are not processed.

func (Scanner) DateFormats

func (s Scanner) DateFormats() (date, time, datetime string)

func (*Scanner) Line

func (s *Scanner) Line(ctx context.Context) (Line, error)

Line processes a single line.

func (Scanner) MatchExcludes

func (s Scanner) MatchExcludes(line Line) bool

Source Files

logscan.go

Version
v2.5.0 (latest)
Published
Dec 14, 2023
Platform
linux/amd64
Imports
13 packages
Last checked
1 day ago

Tools for package owners.