logsreader

package
v0.0.0-...-2f4e5d5 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2017 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoStateFile = errors.New("state file doesn't exist")

ErrNoStateFile indicates that state file doesn't exist. Most likely this happens because server is being processed first time

Functions

func SaveState

func SaveState(conn ConnectionInfo, stats State) error

SaveState saves State for given server

Types

type ConnectionInfo

type ConnectionInfo struct {
	Address  string
	Port     int
	UserName string
	Password string
}

ConnectionInfo represents information about connection to server with nginx logs

func (ConnectionInfo) ServerName

func (conn ConnectionInfo) ServerName() string

ServerName returns server name as Address:Port

func (ConnectionInfo) String

func (conn ConnectionInfo) String() string

type FileInfo

type FileInfo struct {
	Name         string
	ModifiedDate int64
}

FileInfo provides information about file

type LogRecord

type LogRecord struct {
	IPAddress      string
	Time           time.Time
	Duration       float64
	Verb           string
	Path           string
	HTTPStatusCode int
	Size           int
	Domain         string
	Referrer       string
	UserAgent      string
}

LogRecord represents a line of nginx log file

type State

type State struct {
	// NotZippedLogFile stores the name of only log file that was not zipped yet except access.log.
	// If this name changes it means that nginx has started new log file and archived access.log that we were reading last time
	RotatedLog FileInfo

	// BytesRead stores Number of bytes that were already read from access.log
	BytesRead int
}

State store information about state from previous connection

func GetState

func GetState(conn ConnectionInfo) (State, error)

GetState returns State object for given server

func ReadLogs

func ReadLogs(conn ConnectionInfo, readerState State, recordProcessor func(*LogRecord)) (*State, error)

ReadLogs read logs from server

Jump to

Keyboard shortcuts

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