def _flush(self):
    logs = self.parse_logs()
 
    appid = os.environ['APPLICATION_ID']
    if appid in ['apichecker', 'appscaledashboard']:
      self._clear()
      return
 
    formatted_logs = [{'timestamp' : log[0] / 1e6, 
      'level' : log[1] + 1,
      'message' : log[2]} for log in logs]
 
    if not formatted_logs:
      return
 
    payload = json.dumps({
      'service_name' : appid,
      'host' : os.environ['MY_IP_ADDRESS'],
      'logs' : formatted_logs
    })

    SendLogsThread(payload, os.environ["NGINX_HOST"]).start()
    self._clear()

    # AppScale: This currently causes problems when we try to call API requests
    # via new threads, so since we don't have support for the Logs API at the
    # moment, this return prevents the Exception that would be thrown from
    # occurring.
    # TODO: Revisit this problem when we do decide to implement
    # the Logs API.
    return

    first_iteration = True
    while logs or first_iteration:
      first_iteration = False
      request = log_service_pb.FlushRequest()
      group = log_service_pb.UserAppLogGroup()
      byte_size = 0
      n = 0
      for entry in logs:


        if len(entry[2]) > LogsBuffer._MAX_LINE_SIZE:
          entry = list(entry)
          entry[2] = self._truncate(entry[2], LogsBuffer._MAX_LINE_SIZE)


        if byte_size + len(entry[2]) > LogsBuffer._MAX_FLUSH_SIZE:
          break
        line = group.add_log_line()
        line.set_timestamp_usec(entry[0])
        line.set_level(entry[1])
        line.set_message(entry[2])
        byte_size += 1 + group.lengthString(line.ByteSize())
        n += 1
      assert n > 0 or not logs
      logs = logs[n:]
      request.set_logs(group.Encode())
      response = api_base_pb.VoidProto()
      apiproxy_stub_map.MakeSyncCall('logservice', 'Flush', request, response)
Internal version of flush() with no locking.
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/api/logservice/logservice.py/LogsBuffer._flush