apachelog

package module
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2016 License: MIT Imports: 11 Imported by: 19

README

go-apache-logformat

Build Status

Coverage Status

SYNOPSYS

import (
  "net/http"
  "os"

  "github.com/lestrrat/go-apache-logformat"
)

func main() {
  var s http.ServeMux
  s.HandleFunc("/", handleIndex)
  s.HandleFunc("/foo", handleFoo)

  http.ListenAndServe(":8080", apachelog.CombinedLog.Wrap(s, os.Stderr))
}

DESCRIPTION

This is a port of Perl5's Apache::LogFormat::Compiler to golang

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidRuneSequence = errors.New("invalid rune sequence found in format")
	ErrUnimplemented       = errors.New("pattern unimplemented")
)
View Source
var CombinedLog, _ = New(`%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-agent}i"`)

Combined is a pre-defined ApacheLog struct to log "combined" log format

View Source
var CommonLog, _ = New(`%h %l %u %t "%r" %>s %b`)

Combined is a pre-defined ApacheLog struct to log "common" log format

Functions

This section is empty.

Types

type ApacheLog

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

func New

func New(format string) (*ApacheLog, error)

func (*ApacheLog) Wrap

func (al *ApacheLog) Wrap(h http.Handler, dst io.Writer) http.Handler

Wrap creates a new http.Handler that logs a formatted log line to dst.

func (*ApacheLog) WriteLog

func (al *ApacheLog) WriteLog(dst io.Writer, ctx *LogCtx) error

type Format

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

Format describes an Apache log format. Given a logging context, it can create a log line.

func (*Format) WriteTo

func (f *Format) WriteTo(dst io.Writer, ctx *LogCtx) error

type FormatWriteFunc

type FormatWriteFunc func(io.Writer, *LogCtx) error

func (FormatWriteFunc) WriteTo

func (f FormatWriteFunc) WriteTo(dst io.Writer, ctx *LogCtx) error

type FormatWriter

type FormatWriter interface {
	WriteTo(io.Writer, *LogCtx) error
}

type LogCtx

type LogCtx struct {
	Request        *http.Request
	RequestTime    time.Time
	ResponseStatus int
	ResponseHeader http.Header
	ElapsedTime    time.Duration
}

Jump to

Keyboard shortcuts

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