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/include/netdutils/Log.h b/libnetdutils/include/netdutils/Log.h
index 90715db..2e94fdf 100644
--- a/libnetdutils/include/netdutils/Log.h
+++ b/libnetdutils/include/netdutils/Log.h
@@ -55,6 +55,8 @@
// Convenience methods for each of the common types of function arguments.
LogEntry& arg(const std::string& val);
+ // Intended for binary buffers, formats as hex
+ LogEntry& arg(const std::vector<uint8_t>& val);
LogEntry& arg(const std::vector<int32_t>& val);
LogEntry& arg(const std::vector<std::string>& val);
template <typename IntT, typename = std::enable_if_t<std::is_arithmetic_v<IntT>>>
@@ -67,10 +69,11 @@
template <>
LogEntry& arg<>(bool val);
- template <typename... Args> LogEntry& args(const Args&... a) {
+ template <typename... Args>
+ LogEntry& args(const Args&... a) {
// Cleverness ahead: we throw away the initializer_list filled with
// zeroes, all we care about is calling arg() for each argument.
- (void)std::initializer_list<int>{ (arg(a), 0)... };
+ (void) std::initializer_list<int>{(arg(a), 0)...};
return *this;
}