axslogparser

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: MIT Imports: 8 Imported by: 10

README

axslogparser

Build Status Coverage Status MIT License GoDoc

Description

An accesslog parser supports apache log (common and combined) and ltsv accesslog (http://ltsv.org).

Supported Formats

  • Apache Logs (also cared in the case of using tab character as delimiter)
    • Common log format
    • Common log format with vhost
    • Combined log format
    • Combined log format with extra fields
  • LTSV Accesslog format according to http://ltsv.org

Author

Songmu

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GuessParser

func GuessParser(line string) (Parser, *Log, error)

GuessParser guesses the parser from line, uses default parsers for each format

Types

type Apache

type Apache struct {
	// If set to true, ignores non-fatal errors while parsing line,
	// which may leave some fields empty or invalid.
	Loose bool
}

Apache log parser

func (*Apache) Parse

func (ap *Apache) Parse(line string) (*Log, error)

Parse for Parser interface

type LTSV

type LTSV struct {
	// If set to true, ignores non-fatal errors while parsing line,
	// which may leave some fields empty or invalid.
	Loose bool
}

LTSV access log parser

func (*LTSV) Parse

func (lv *LTSV) Parse(line string) (*Log, error)

Parse for Parser interface

type Log

type Log struct {
	VirtualHost     string `ltsv:"vhost"`
	Host            string
	RemoteLogname   string `ltsv:"ident"`
	User            string
	Time            time.Time `ltsv:"-"`
	TimeStr         string    `ltsv:"time"`
	Request         string    `ltsv:"req"`
	Status          int
	Size            uint64
	Referer         string
	UserAgent       string `ltsv:"ua"`
	ReqTime         *float64
	ReqTimeMicroSec *float64 `ltsv:"reqtime_microsec"`
	AppTime         *float64
	TakenSec        *float64 `ltsv:"taken_sec"` // Hatena specific
	ForwardedFor    string
	RequestURI      string `ltsv:"uri"`
	Protocol        string
	Method          string
}

Log is the struct stored parsed result of single line of accesslog

func Parse

func Parse(line string) (*Log, error)

Parse log line using default parsers

type Parser

type Parser interface {
	Parse(string) (*Log, error)
}

Parser is the interface for accesslog

type Parsers added in v1.4.0

type Parsers struct {
	Apache *Apache
	LTSV   *LTSV
}

Parsers represents a set of available parsers

func (Parsers) GuessParser added in v1.4.0

func (ps Parsers) GuessParser(line string) (Parser, *Log, error)

GuessParser guesses the parser from line

func (Parsers) Parse added in v1.4.0

func (ps Parsers) Parse(line string) (*Log, error)

Parse log line

Jump to

Keyboard shortcuts

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