Pre-defined log fields
const ( FieldUsername = "username" FieldTimestamp = "timestamp" FieldElapsedTime = "elapsed" FieldResponseSize = "size" )
DefaultLogger logs to stderr.
var DefaultLogger = New(os.Stderr)
Fields is simple wrapper around logging fields.
type Fields map[string]interface{}
func (f Fields) Exists(key string) bool
Exists returns true if the requested key exists in the map.
func (f Fields) Get(key string) interface{}
Get returns the value associated with a key.
func (f Fields) GetDuration(key string) time.Duration
GetDuration returns a value as a time.Duration
func (f Fields) GetInt(key string) int
GetInt returns a value as an int.
func (f Fields) GetString(key string) string
GetString returns a value as a string, or "-"
func (f Fields) GetTime(key string) time.Time
GetTime returns a value as a timestamp.
RequestLogger is a request logger.
type RequestLogger interface { Log(req *http.Request, status int, fields Fields) }
func New(w io.Writer) RequestLogger
New returns a new RequestLogger that writes apache-style logs to an io.Writer.