瀏覽代碼

router logger did not show username in /render calls because cookies are
cleared in these call. Not just get username before the call is
executed. see #3405 for more info.

Piotr Popieluch 10 年之前
父節點
當前提交
e29e3416db
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      pkg/middleware/logger.go

+ 3 - 3
pkg/middleware/logger.go

@@ -29,14 +29,14 @@ func Logger() macaron.Handler {
 	return func(res http.ResponseWriter, req *http.Request, c *macaron.Context) {
 		start := time.Now()
 
-		rw := res.(macaron.ResponseWriter)
-		c.Next()
-
 		uname := c.GetCookie(setting.CookieUserName)
 		if len(uname) == 0 {
 			uname = "-"
 		}
 
+		rw := res.(macaron.ResponseWriter)
+		c.Next()
+
 		content := fmt.Sprintf("Completed %s %s \"%s %s %s\" %v %s %d bytes in %dus", c.RemoteAddr(), uname, req.Method, req.URL.Path, req.Proto, rw.Status(), http.StatusText(rw.Status()), rw.Size(), time.Since(start)/time.Microsecond)
 
 		switch rw.Status() {