mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 19:10:54 +00:00
Add .Elapsed in context.ResponseWriter for monitor purpose
With this commit we can record per requests's elapsed time, so we can easy to monitor that by use a filter.
This commit is contained in:
parent
7a50ea7e36
commit
b021686521
@ -201,6 +201,7 @@ type Response struct {
|
|||||||
http.ResponseWriter
|
http.ResponseWriter
|
||||||
Started bool
|
Started bool
|
||||||
Status int
|
Status int
|
||||||
|
Elapsed time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Response) reset(rw http.ResponseWriter) {
|
func (r *Response) reset(rw http.ResponseWriter) {
|
||||||
|
@ -890,8 +890,9 @@ Admin:
|
|||||||
|
|
||||||
logAccess(context, &startTime, statusCode)
|
logAccess(context, &startTime, statusCode)
|
||||||
|
|
||||||
|
timeDur := time.Since(startTime)
|
||||||
|
context.ResponseWriter.Elapsed = timeDur
|
||||||
if BConfig.Listen.EnableAdmin {
|
if BConfig.Listen.EnableAdmin {
|
||||||
timeDur := time.Since(startTime)
|
|
||||||
pattern := ""
|
pattern := ""
|
||||||
if routerInfo != nil {
|
if routerInfo != nil {
|
||||||
pattern = routerInfo.pattern
|
pattern = routerInfo.pattern
|
||||||
@ -908,7 +909,6 @@ Admin:
|
|||||||
|
|
||||||
if BConfig.RunMode == DEV && !BConfig.Log.AccessLogs {
|
if BConfig.RunMode == DEV && !BConfig.Log.AccessLogs {
|
||||||
var devInfo string
|
var devInfo string
|
||||||
timeDur := time.Since(startTime)
|
|
||||||
iswin := (runtime.GOOS == "windows")
|
iswin := (runtime.GOOS == "windows")
|
||||||
statusColor := logs.ColorByStatus(iswin, statusCode)
|
statusColor := logs.ColorByStatus(iswin, statusCode)
|
||||||
methodColor := logs.ColorByMethod(iswin, r.Method)
|
methodColor := logs.ColorByMethod(iswin, r.Method)
|
||||||
|
Loading…
Reference in New Issue
Block a user