logger

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldUsername     = "username"
	FieldTimestamp    = "timestamp"
	FieldElapsedTime  = "elapsed"
	FieldResponseSize = "size"
)

Pre-defined log fields

Variables

View Source
var DefaultLogger = New(os.Stderr)

DefaultLogger logs to stderr.

Functions

This section is empty.

Types

type Fields

type Fields map[string]interface{}

Fields is simple wrapper around logging fields.

func (Fields) Exists

func (f Fields) Exists(key string) bool

Exists returns true if the requested key exists in the map.

func (Fields) Get

func (f Fields) Get(key string) interface{}

Get returns the value associated with a key.

func (Fields) GetDuration

func (f Fields) GetDuration(key string) time.Duration

GetDuration returns a value as a time.Duration

func (Fields) GetInt

func (f Fields) GetInt(key string) int

GetInt returns a value as an int.

func (Fields) GetString

func (f Fields) GetString(key string) string

GetString returns a value as a string, or "-"

func (Fields) GetTime

func (f Fields) GetTime(key string) time.Time

GetTime returns a value as a timestamp.

type RequestLogger

type RequestLogger interface {
	Log(req *http.Request, status int, fields Fields)
}

RequestLogger is a request logger.

func New

func New(w io.Writer) RequestLogger

New returns a new RequestLogger that writes apache-style logs to an io.Writer.

Jump to

Keyboard shortcuts

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