mirror of
https://github.com/kataras/iris.git
synced 2025-03-14 08:26:26 +01:00
example: minor
This commit is contained in:
parent
61a9eff43e
commit
d17a888dc1
|
@ -6,4 +6,4 @@
|
|||
2020-09-08 13:41:47|0s|GET|/user/kataras|username=kataras a_query_parameter=name|200|774 B|91 B||Hello, kataras!|
|
||||
2020-09-08 20:37:33|0s|GET|/admin|auth=admin:admin|200|608 B|164 B||<h2>Username: admin</h2><h3>Password: admin</h3>|
|
||||
2020-09-09 07:56:00|738.1µs|GET|/session|session_id=23fe763f-c9d5-4d65-9e1a-2cc8d23d1aa3 session_test_key=session_test_value|200|818 B|302 B||OK|
|
||||
2020-09-09 08:19:13|2.0053069s|GET|/fields|fieldsHandler_latency=2s|200|570 B|130 B||OK|
|
||||
2020-09-09 08:36:47|2.0095505s|GET|/fields|job_latency=2s|200|544 B|130 B||OK|
|
||||
|
|
|
@ -156,13 +156,14 @@ func sessionHandler(ctx iris.Context) {
|
|||
}
|
||||
|
||||
func fieldsHandler(ctx iris.Context) {
|
||||
now := time.Now()
|
||||
logFields := accesslog.GetFields(ctx)
|
||||
defer func() {
|
||||
logFields.Set("fieldsHandler_latency", time.Since(now).Round(time.Second))
|
||||
}()
|
||||
|
||||
// simulate a heavy job...
|
||||
start := time.Now()
|
||||
time.Sleep(2 * time.Second)
|
||||
end := time.Since(start)
|
||||
// Get the current fields instance and use
|
||||
// them to it custom log values.
|
||||
logFields := accesslog.GetFields(ctx)
|
||||
logFields.Set("job_latency", end.Round(time.Second))
|
||||
|
||||
ctx.WriteString("OK")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user