aboutsummaryrefslogtreecommitdiff
path: root/src/logging
diff options
context:
space:
mode:
authorMartin Ankerl <martin.ankerl@gmail.com>2021-09-07 18:16:09 +0200
committerJon Atack <jon@atack.com>2021-09-07 19:19:31 +0200
commitf530202353a4f8bb444966559aa15681ab3cebc6 (patch)
tree28d30a3f11b852475a1bef220b8a0c24caffd35a /src/logging
parentbddae7e7ff7bb5931ed807acaef7336f2ee98476 (diff)
downloadbitcoin-f530202353a4f8bb444966559aa15681ab3cebc6.tar.xz
Make unexpected time type in BCLog::LogMsg() a compile-time error
Diffstat (limited to 'src/logging')
-rw-r--r--src/logging/timer.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/logging/timer.h b/src/logging/timer.h
index 6d584084ca..79627b1fe3 100644
--- a/src/logging/timer.h
+++ b/src/logging/timer.h
@@ -9,6 +9,7 @@
#include <logging.h>
#include <util/macros.h>
#include <util/time.h>
+#include <util/types.h>
#include <chrono>
#include <string>
@@ -58,14 +59,14 @@ public:
return strprintf("%s: %s", m_prefix, msg);
}
- if (std::is_same<TimeType, std::chrono::microseconds>::value) {
+ if constexpr (std::is_same<TimeType, std::chrono::microseconds>::value) {
return strprintf("%s: %s (%iμs)", m_prefix, msg, end_time.count());
- } else if (std::is_same<TimeType, std::chrono::milliseconds>::value) {
+ } else if constexpr (std::is_same<TimeType, std::chrono::milliseconds>::value) {
return strprintf("%s: %s (%.2fms)", m_prefix, msg, end_time.count() * 0.001);
- } else if (std::is_same<TimeType, std::chrono::seconds>::value) {
+ } else if constexpr (std::is_same<TimeType, std::chrono::seconds>::value) {
return strprintf("%s: %s (%.2fs)", m_prefix, msg, end_time.count() * 0.000001);
} else {
- return "Error: unexpected time type";
+ static_assert(ALWAYS_FALSE<TimeType>, "Error: unexpected time type");
}
}
@@ -81,7 +82,6 @@ private:
//! Forwarded on to LogPrint if specified - has the effect of only
//! outputting the timing log when a particular debug= category is specified.
const BCLog::LogFlags m_log_category{};
-
};
} // namespace BCLog