code: def _as_log_entry(self, name, now):
          
          # initialize the struct with fields that are always present
          d = {
              u'http_response_code': self.response_code,
              u'timestamp': time.mktime(now.timetuple())
          }
  
          # compute the severity
          severity = _SEVERITY.INFO
          if self.response_code >= 400:
              severity = _SEVERITY.ERROR
              d[u'error_cause'] = self.error_cause.name
  
          # add 'optional' fields to the struct
          if self.request_size > 0:
              d[u'request_size'] = self.request_size
          if self.response_size > 0:
              d[u'response_size'] = self.response_size
          if self.method:
              d[u'http_method'] = self.method
          if self.request_time:
              d[u'request_latency_in_ms'] = self.request_time.total_seconds() * 1000
  
          # add 'copyable' fields to the struct
          for key in self.COPYABLE_LOG_FIELDS:
              value = getattr(self, key, None)
              if value:
                  d[key] = value
  
          return sc_messages.LogEntry(
              name=name,
              timestamp=timestamp.to_rfc3339(now),
              severity=severity,
              structPayload=_struct_payload_from(d))
docs: Makes a `LogEntry` from this instance for the given log_name.
  
          Args:
            rules (:class:`ReportingRules`): determines what labels, metrics and
              logs to include in the report request.
            now (:class:`datetime.DateTime`): the current time
  
          Return:
            a ``LogEntry`` generated from this instance with the given name
            and timestamp
  
          Raises:
            ValueError: if the fields in this instance are insufficient to
              to create a valid ``ServicecontrolServicesReportRequest``