You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/05/24 17:51:10 UTC
[GitHub] ccollins476ad commented on a change in pull request #1135: log: Add
better support for long log entries in nmgr
ccollins476ad commented on a change in pull request #1135: log: Add better support for long log entries in nmgr
URL: https://github.com/apache/mynewt-core/pull/1135#discussion_r190673903
##########
File path: sys/log/full/src/log_nmgr.c
##########
@@ -159,21 +129,41 @@ log_nmgr_encode_entry(struct log *log, struct log_offset *log_offset,
case LOG_ETYPE_CBOR:
g_err |= cbor_encode_text_stringz(&rsp, "type");
g_err |= cbor_encode_text_stringz(&rsp, "cbor");
- /* Just encode something short and CBOR stream will be inserted here later */
- g_err |= cbor_encode_text_stringz(&rsp, "msg");
- g_err |= cbor_encode_undefined(&rsp);
- rsp_len += dlen;
break;
- case LOG_ETYPE_STRING:
case LOG_ETYPE_BINARY:
+ g_err |= cbor_encode_text_stringz(&rsp, "type");
+ g_err |= cbor_encode_text_stringz(&rsp, "bin");
+ break;
+ case LOG_ETYPE_STRING:
default:
- g_err |= cbor_encode_text_stringz(&rsp, "msg");
- g_err |= cbor_encode_text_stringz(&rsp, data);
+ /* no need for type here */
+ g_err |= cbor_encode_text_stringz(&rsp, "type");
+ g_err |= cbor_encode_text_stringz(&rsp, "str");
break;
}
+
+ g_err |= cbor_encode_text_stringz(&rsp, "msg");
+
+ /*
+ * Write entry data as byte string. Since this may not fit into single
+ * chunk of data we will write as indefinite-length byte string which is
+ * basically a indefinite-length container with definite-length strings
+ * inside.
+ */
+ g_err |= cbor_encoder_create_indef_byte_string(&rsp, &str_encoder);
+ for (off = sizeof(ueh); (off < len) && !g_err; ) {
+ rc = log_read(log, dptr, data, off, sizeof(data));
+ if (rc < 0) {
+ g_err |= 1;
+ break;
+ }
+ g_err |= cbor_encode_byte_string(&str_encoder, data, rc);
+ off += rc;
+ }
+ g_err |= cbor_encoder_close_container(&rsp, &str_encoder);
#else
g_err |= cbor_encode_text_stringz(&rsp, "msg");
- g_err |= cbor_encode_text_stringz(&rsp, data);
+ g_err |= cbor_encode_byte_string(&rsp, data, strlen((char *)data));
Review comment:
We shouldn't change the format of V2 log entries, should we? I.e., shouldn't `msg` still be a text string here?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services