- /* Compose content. Add a new-line (replacing the null terminator) to make
- * the file easier to read, even though it has no semantic value. */
- json_string = json_to_string(json, 0);
- length = strlen(json_string) + 1;
- json_string[length - 1] = '\n';
-
- /* Compose header. */
- sha1_bytes(json_string, length, sha1);
- snprintf(header, sizeof header, "%s%zu "SHA1_FMT"\n",
- magic, length, SHA1_ARGS(sha1));
-
- /* Write. */
- if (fwrite(header, strlen(header), 1, file->stream) != 1
- || fwrite(json_string, length, 1, file->stream) != 1
- || fflush(file->stream))
- {
- error = ovsdb_io_error(errno, "%s: write failed", file->name);
-
- /* Remove any partially written data, ignoring errors since there is
- * nothing further we can do. */
- ftruncate(fileno(file->stream), file->offset);
-
- goto error;
+ json_object_put(aux.json, "_date", json_integer_create(time_now()));
+
+ error = ovsdb_log_write(r->log, aux.json);
+ json_destroy(aux.json);
+ if (error) {
+ return ovsdb_wrap_error(error, "writing transaction failed");