aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/_nuts/github.com/go-martini/martini/logger.go
diff options
context:
space:
mode:
authorTeddy Wing2015-06-06 19:25:17 -0400
committerTeddy Wing2015-06-06 19:25:17 -0400
commit1135764727f3dc525d0f674c784edbc81cc786f3 (patch)
tree5c402c88d3a07a3cde84237ead5829bda28f3e25 /vendor/_nuts/github.com/go-martini/martini/logger.go
downloadNew-House-on-the-Block-1135764727f3dc525d0f674c784edbc81cc786f3.tar.bz2
Initial commit. Install coinbase-go.
* Use nut for vendored dependencies * Install coinbase-go to interact with the Coinbase API
Diffstat (limited to 'vendor/_nuts/github.com/go-martini/martini/logger.go')
-rw-r--r--vendor/_nuts/github.com/go-martini/martini/logger.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/vendor/_nuts/github.com/go-martini/martini/logger.go b/vendor/_nuts/github.com/go-martini/martini/logger.go
new file mode 100644
index 0000000..d01107c
--- /dev/null
+++ b/vendor/_nuts/github.com/go-martini/martini/logger.go
@@ -0,0 +1,29 @@
+package martini
+
+import (
+ "log"
+ "net/http"
+ "time"
+)
+
+// Logger returns a middleware handler that logs the request as it goes in and the response as it goes out.
+func Logger() Handler {
+ return func(res http.ResponseWriter, req *http.Request, c Context, log *log.Logger) {
+ start := time.Now()
+
+ addr := req.Header.Get("X-Real-IP")
+ if addr == "" {
+ addr = req.Header.Get("X-Forwarded-For")
+ if addr == "" {
+ addr = req.RemoteAddr
+ }
+ }
+
+ log.Printf("Started %s %s for %s", req.Method, req.URL.Path, addr)
+
+ rw := res.(ResponseWriter)
+ c.Next()
+
+ log.Printf("Completed %v %s in %v\n", rw.Status(), http.StatusText(rw.Status()), time.Since(start))
+ }
+}