+ logiov[0].iov_base = ptr;
+ logiov[0].iov_len = len;
+ int iovs_to_write = 1;
+
+ // Do we need the second span?
+ if (! will_complete && len != log_buffer.get_length()) {
+ ptr = log_buffer.get_buf_base();
+ creptr = static_cast<char *>(logiov[1].iov_base) + log_buffer.get_length() - len;
+ eptr = std::find(ptr, creptr, '\n');
+ if (eptr != creptr) {
+ eptr++; // include '\n'
+ // It should not ever be the case that we do not now have a complete message
+ will_complete = true;
+ }
+ logiov[1].iov_base = ptr;
+ logiov[1].iov_len = eptr - ptr;
+ len += logiov[1].iov_len;
+ iovs_to_write = 2;
+ }
+
+ ssize_t r = writev(fd, logiov, iovs_to_write);