6 #ifndef BITCOIN_LOGGING_TIMER_H
7 #define BITCOIN_LOGGING_TIMER_H
21 template <
typename TimeType>
31 bool msg_on_completion =
true) :
38 m_start_t = GetTime<std::chrono::microseconds>();
46 this->
Log(
"completed");
50 void Log(
const std::string& msg)
52 const std::string full_msg = this->
LogMsg(msg);
61 std::string
LogMsg(
const std::string& msg)
63 const auto end_time = GetTime<std::chrono::microseconds>() -
m_start_t;
68 if constexpr (std::is_same<TimeType, std::chrono::microseconds>::value) {
70 }
else if constexpr (std::is_same<TimeType, std::chrono::milliseconds>::value) {
72 }
else if constexpr (std::is_same<TimeType, std::chrono::seconds>::value) {
75 static_assert(ALWAYS_FALSE<TimeType>,
"Error: unexpected time type");
99 #define LOG_TIME_MICROS_WITH_CATEGORY(end_msg, log_category) \
100 BCLog::Timer<std::chrono::microseconds> UNIQUE_NAME(logging_timer)(__func__, end_msg, log_category)
101 #define LOG_TIME_MILLIS_WITH_CATEGORY(end_msg, log_category) \
102 BCLog::Timer<std::chrono::milliseconds> UNIQUE_NAME(logging_timer)(__func__, end_msg, log_category)
103 #define LOG_TIME_MILLIS_WITH_CATEGORY_MSG_ONCE(end_msg, log_category) \
104 BCLog::Timer<std::chrono::milliseconds> UNIQUE_NAME(logging_timer)(__func__, end_msg, log_category, false)
105 #define LOG_TIME_SECONDS(end_msg) \
106 BCLog::Timer<std::chrono::seconds> UNIQUE_NAME(logging_timer)(__func__, end_msg)
109 #endif // BITCOIN_LOGGING_TIMER_H