http/log/log.go
func (lh *commonLogHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
	// take a copy of the request (so it's immutable)
	// watch the writer and capture the status and size
	logData := LogData{
		Request:  *req,
		Response: WatchResponseWriter(w),
	}

	logData.Start = time.Now()
	lh.handler.ServeHTTP(logData.Response, req)
	logData.End = time.Now()

	logOutput := bytes.Buffer{}
	err := lh.template.Execute(&logOutput, logData)
	if err != nil {
		panic(err)
	}

	lh.logger.Println(logOutput.String())
}
func (lh *commonLogHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
	// take a copy of the request (so it's immutable)
	// watch the writer and capture the status and size
	logData := LogData{
		Request:  *req,
		Response: WatchResponseWriter(w),
	}

	logData.Start = time.Now()
	lh.handler.ServeHTTP(logData.Response, req)
	logData.End = time.Now()

	logOutput := bytes.Buffer{}
	err := lh.template.Execute(&logOutput, logData)
	if err != nil {
		panic(err)
	}

	lh.logger.Println(logOutput.String())
}
func ( lh * commonLogHandler ) ServeHTTP ( w http . ResponseWriter , req * http . Request ) { // take a copy of the request (so it's immutable) // watch the writer and capture the status and size logData := LogData { Request : * req , Response : WatchResponseWriter ( w ) , } logData . Start = time . Now ( ) lh . handler . ServeHTTP ( logData . Response , req ) logData . End = time . Now ( ) logOutput := bytes . Buffer { } err := lh . template . Execute ( & logOutput , logData ) if err != nil { panic ( err ) } lh . logger . Println ( logOutput . String ( ) ) }
// ServeHTTP logs the request and response data to Common Log Format
ServeHTTP logs the request and response data to Common Log Format