apachelog

package module
v0.0.0-...-bb93a01 Latest Latest
Warning

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

Go to latest
Published: May 5, 2015 License: MIT Imports: 7 Imported by: 2

README

go-apachelog is deprecated. See github.com/cespare/hutil/apachelog instead

go-apachelog

This is a small library to write your server logs in Apache Common Log Format. See the documentation for usage instructions.

The code is mostly based on logging.go in Camlistore.

Documentation

Overview

Package apachelog is a library for logging the responses of an http.Handler in the Apache Common Log Format. It uses a variant of this log format (http://httpd.apache.org/docs/1.3/logs.html#common) also used by Rack::CommonLogger in Ruby. The format has an additional field at the end for the response time in seconds.

Using apachelog is typically very simple. You'll need to create an http.Handler and set up your request routing first. In a simple web application, for example, you might just use http.NewServeMux(). Next, wrap the http.Handler in an apachelog handler using NewHandler, create an http.Server with this handler, and you're good to go.

Example:

mux := http.NewServeMux()
mux.HandleFunc("/", handler)
loggingHandler := apachelog.NewHandler(mux, os.Stderr)
server := &http.Server{
	Addr: ":8899",
	Handler: loggingHandler,
}
server.ListenAndServe()

Index

Constants

This section is empty.

Variables

View Source
var ErrHijackingNotSupported = errors.New("hijacking is not supported")

Functions

func NewHandler

func NewHandler(h http.Handler, out io.Writer) http.Handler

NewHandler creates a new http.Handler, given some underlying http.Handler to wrap and an output stream (typically os.Stderr).

Types

This section is empty.

Jump to

Keyboard shortcuts

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