1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-19 02:47:04 +00:00

example: minor

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-09-09 08:37:26 +03:00
parent 61a9eff43e
commit d17a888dc1
2 changed files with 8 additions and 7 deletions

View File

@@ -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")
}