docs: async def access_log_middleware(app, handler):
      """Log each request in structured event log."""
  
      event_log = app.get('smartmob.event_log') or structlog.get_logger()
      clock = app.get('smartmob.clock') or timeit.default_timer
  
      # Keep the request arrival time to ensure we get intuitive logging of
      # events.
      arrival_time = datetime.utcnow().replace(tzinfo=timezone.utc)
  
      async def access_log(request):
          ref = clock()
          try:
              response = await handler(request)
              event_log.info(
                  'http.access',
                  path=request.path,
                  outcome=response.status,
                  duration=(clock()-ref),
                  request=request.get('x-request-id', '?'),
                  **{'@timestamp': arrival_time}
              )
              return response
          except web.HTTPException as error:
              event_log.info(
                  'http.access',
                  path=request.path,
                  outcome=error.status,
                  duration=(clock()-ref),
                  request=request.get('x-request-id', '?'),
                  **{'@timestamp': arrival_time}
              )
              raise
          except Exception:
              event_log.info(
                  'http.access',
                  path=request.path,
                  outcome=500,
                  duration=(clock()-ref),
                  request=request.get('x-request-id', '?'),
                  **{'@timestamp': arrival_time}
              )
              raise
  
      return access_log