1
0
Fork 0
mirror of https://github.com/vbatts/imgsrv.git synced 2024-12-24 23:06:31 +00:00

moved LogRequest to github.com/vbatts/go-httplog

This commit is contained in:
Vincent Batts 2013-06-18 15:17:44 -04:00
parent 921fee9529
commit 7688ec2e10

View file

@ -2,13 +2,11 @@ package util
import (
"crypto/tls"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"path/filepath"
"strings"
"time"
)
@ -56,29 +54,3 @@ func FetchFileFromURL(url string) (filename string, err error) {
return filepath.Join(os.TempDir(), url_filename), nil
}
/* kindof a common log type output */
func LogRequest(r *http.Request, statusCode int) {
var addr string
var user_agent string
user_agent = ""
addr = r.RemoteAddr
for k, v := range r.Header {
if k == "User-Agent" {
user_agent = strings.Join(v, " ")
}
if k == "X-Forwarded-For" {
addr = strings.Join(v, " ")
}
}
fmt.Printf("%s - - [%s] \"%s %s\" \"%s\" %d %d\n",
addr,
time.Now(),
r.Method,
r.URL.String(),
user_agent,
statusCode,
r.ContentLength)
}