mirror of
https://github.com/vbatts/imgsrv.git
synced 2024-11-27 02:25:41 +00:00
moved LogRequest to github.com/vbatts/go-httplog
This commit is contained in:
parent
921fee9529
commit
7688ec2e10
1 changed files with 0 additions and 28 deletions
28
util/util.go
28
util/util.go
|
@ -2,13 +2,11 @@ package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -56,29 +54,3 @@ func FetchFileFromURL(url string) (filename string, err error) {
|
||||||
return filepath.Join(os.TempDir(), url_filename), nil
|
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)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue