log

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2018 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

Package log provides handlers for logging request access and panics.

Index

Constants

View Source
const AccessDateFormat = "Jan 2, 2006 at 3:04pm (MST)"

AccessDateFormat is the default timestamp format for the access log messages.

View Source
const PanicDateFormat = "Jan 2, 2006 at 3:04pm (MST)"

PanicDateFormat is the default timestamp format for the panic messages.

Variables

This section is empty.

Functions

func Access

func Access(h http.Handler, opts ...Option) http.Handler

Access returns a handler that writes an access log message to the provided logger, provided by the options, whenever the handler h is invoked. The log message is of the following format:

IP - USER [DATETIME - DURATION] "HTTP_METHOD URI" STATUS_CODE BODY_LENGTH "REFERER" USER_AGENT

By default, all messages are printed to os.Stdout.

func Panic

func Panic(h http.Handler, opts ...Option) http.Handler

Panic returns a handler that invokes the passed handler h, catching any panics. If one occurs, an HTTP 500 response is produced.

By default, all messages are printed out to os.Stderr.

Types

type Option

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

An Option is used to change the default behaviour of logging handlers.

var (
	// ShowStack will cause the stack to be printed out in the
	// http.ResponseWriter. Only used by the Panic handler.
	ShowStack Option = showStack
)

func DateFormat

func DateFormat(f string) Option

DateFormat is used to format the timestamp.

func Logger

func Logger(l handler.Logger) Option

Logger defines the logger to be used whenever detailed messages have to be printed out.

Jump to

Keyboard shortcuts

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