Add a Log::arg() variant to hexdump binary buffers
Perhaps we should make this work with Slices, easy to add once the need
arises.
Test: atest netdutils_test
Change-Id: I031b8e41e9ab7b59a857e77438bc3fa193e755b3
diff --git a/libnetdutils/Log.cpp b/libnetdutils/Log.cpp
index 1a742f6..d2ce98f 100644
--- a/libnetdutils/Log.cpp
+++ b/libnetdutils/Log.cpp
@@ -15,6 +15,7 @@
*/
#include "netdutils/Log.h"
+#include "netdutils/Slice.h"
#include <chrono>
#include <ctime>
@@ -117,7 +118,7 @@
return *this;
}
-template<>
+template <>
LogEntry& LogEntry::arg<>(bool val) {
mArgs.push_back(val ? "true" : "false");
return *this;
@@ -128,6 +129,11 @@
return *this;
}
+LogEntry& LogEntry::arg(const std::vector<uint8_t>& val) {
+ mArgs.push_back('{' + toHex(makeSlice(val)) + '}');
+ return *this;
+}
+
LogEntry& LogEntry::arg(const std::vector<std::string>& val) {
mArgs.push_back(StringPrintf("[%s]", Join(val, ", ").c_str()));
return *this;