Documentation ¶
Index ¶
- func AppendQuoted(buf []byte, s string) []byte
- func CombinedLogLine(r LogRequest) []byte
- func CommonLogLine(r LogRequest) []byte
- func LogHandler(handler http.Handler, logger Logger) logHandler
- func ParseHostAndURI(r *http.Request) (string, string)
- func ParseUser(r *http.Request) string
- type LogRequest
- type Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendQuoted ¶
AppendQuoted appends a quoted version of string s to buf.
func CombinedLogLine ¶
func CombinedLogLine(r LogRequest) []byte
CombinedLogLine returns a log entry in Apache Combined Log Format.
See http://httpd.apache.org/docs/2.2/logs.html#combined
Always sets the ident field of the log to -
func CommonLogLine ¶
func CommonLogLine(r LogRequest) []byte
CommonLogLine returns a log entry in Apache Common Log Format (CLF).
See http://httpd.apache.org/docs/2.2/logs.html#common
Always sets the ident field of the log to -
func LogHandler ¶
LogHandler makes a http.Handler (middleware for the Go HTTP server). For each HTTP request, it calls the user-supplied handler. At the end of the request, it additionally calls the user-supplied logger to log the request.
The logger gets a LogRequest. Usually you'll want to call one of the log formatting functions in this package or roll your own log formatter. Then write the resulting log entry somewhere.
func ParseHostAndURI ¶
ParseHostAndURI gets the host and URI from a HTTP request. It tries some tricks if they don't have normal values.
Types ¶
type LogRequest ¶
type LogRequest struct { StartTime time.Time EndTime time.Time User string Host string Method string URI string Proto string Referer string UserAgent string Size int Status int }
LogRequest holds all the logging information pertaining to a single HTTP request. Log formatters turn this struct into a log entry in the desired format. This struct holds the information in a pre-parsed format to make it as easy as possible to write log formatters.
type Logger ¶
type Logger func(r LogRequest)
Logger is any user-supplied function to process one LogRequest.