Documentation
¶
Overview ¶
Package logger allows logging HTTP requests using customized formats.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(*handler)
Option implements http://commandcenter.blogspot.com/2014/01/self-referential-functions-and-design.html
func Flags ¶
Flags allows to set logging flags using Go's standard log flags.
Example: log.LstdFlags | log.shortfile Keep in mind that log.shortfile and log.Llongfile are expensive flags
func Format ¶
Format allows to set a custom log format. Although, the timestamp is always logged at the beginning. This handler is a bit opinionated.
Directives:
{remote_user} : Remote user if Basic Auth credentials were sent {remote_ip} : Remote IP address. {latency} : The time taken to serve the request, in microseconds. {latency_human} : The time taken to serve the request, human readable. {id} : The request ID. {host} : The Host header sent to the server {scheme} : The protocol scheme used, either http or https. {method} : The request method. Ex: GET, POST, DELETE, etc. {url} : The URL path requested. {query} : Request's query string {rxbytes} : Bytes received without headers {txbytes} : Bytes sent, excluding HTTP headers. {status} : Status sent to the client {useragent} : User Agent {referer} : The site from where the request came from