NBLog: add buffer hex dump
Bug: 36724290
Test: create and print entries, check dump matches expected content
Change-Id: I71c4df287535b460838afc2d3ce651744850bf49
diff --git a/media/libnbaio/NBLog.cpp b/media/libnbaio/NBLog.cpp
index de2dc25..834e3ef 100644
--- a/media/libnbaio/NBLog.cpp
+++ b/media/libnbaio/NBLog.cpp
@@ -1018,6 +1018,23 @@
body->appendFormat("<PID: %d, name: %.*s>", id, (int) (length - sizeof(pid_t)), name);
}
+String8 NBLog::bufferHexDump(const uint8_t *buffer, size_t size)
+{
+ String8 str;
+ str.append("[ ");
+ for(size_t i = 0; i < size; i++)
+ {
+ str.appendFormat("%02x ", buffer[i]);
+ }
+ str.append("]");
+ return str;
+}
+
+String8 NBLog::bufferHexDump(const EntryIterator &it)
+{
+ return bufferHexDump(it, it->length + Entry::kOverhead);
+}
+
NBLog::EntryIterator NBLog::Reader::handleFormat(const FormatEntry &fmtEntry,
String8 *timestamp,
String8 *body) {