mirror of
https://github.com/astaxie/beego.git
synced 2024-12-23 04:50:49 +00:00
Merge pull request #3405 from coldnight/feature-add-elapsed-in-response
Add .Elapsed in context.ResponseWriter for monitor purpose
This commit is contained in:
commit
a17eb54515
@ -201,6 +201,7 @@ type Response struct {
|
||||
http.ResponseWriter
|
||||
Started bool
|
||||
Status int
|
||||
Elapsed time.Duration
|
||||
}
|
||||
|
||||
func (r *Response) reset(rw http.ResponseWriter) {
|
||||
@ -259,4 +260,4 @@ func (r *Response) Pusher() (pusher http.Pusher) {
|
||||
return pusher
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -890,8 +890,9 @@ Admin:
|
||||
|
||||
logAccess(context, &startTime, statusCode)
|
||||
|
||||
timeDur := time.Since(startTime)
|
||||
context.ResponseWriter.Elapsed = timeDur
|
||||
if BConfig.Listen.EnableAdmin {
|
||||
timeDur := time.Since(startTime)
|
||||
pattern := ""
|
||||
if routerInfo != nil {
|
||||
pattern = routerInfo.pattern
|
||||
@ -908,7 +909,6 @@ Admin:
|
||||
|
||||
if BConfig.RunMode == DEV && !BConfig.Log.AccessLogs {
|
||||
var devInfo string
|
||||
timeDur := time.Since(startTime)
|
||||
iswin := (runtime.GOOS == "windows")
|
||||
statusColor := logs.ColorByStatus(iswin, statusCode)
|
||||
methodColor := logs.ColorByMethod(iswin, r.Method)
|
||||
|
Loading…
Reference in New Issue
Block a user