sys/log: Make sure watermark is updated for each log after read
Watermark should be updated after entries are properly encoded for each
log.
@@ -454,6 +454,10 @@ log_nmgr_read(struct mgmt_cbuf *cb)
goto err;
}
+#if MYNEWT_VAL(LOG_READ_WATERMARK_UPDATE)
+ log_set_watermark(log, index);
+#endif
+
/* If a log was found, encode and break */
if (name_len > 0) {
break;
@@ -466,10 +470,6 @@ log_nmgr_read(struct mgmt_cbuf *cb)
rc = OS_EINVAL;
}
-#if MYNEWT_VAL(LOG_READ_WATERMARK_UPDATE)
- log_set_watermark(log, index);
-#endif
-
err:
g_err |= cbor_encoder_close_container(&cb->encoder, &logs);
g_err |= cbor_encode_text_stringz(&cb->encoder, "rc");
