@@ -27,18 +27,24 @@ class Timer
27
27
Timer (
28
28
std::string prefix,
29
29
std::string end_msg,
30
- BCLog::LogFlags log_category = BCLog::LogFlags::ALL) :
30
+ BCLog::LogFlags log_category = BCLog::LogFlags::ALL,
31
+ bool msg_on_completion = true ) :
31
32
m_prefix (std::move(prefix)),
32
33
m_title (std::move(end_msg)),
33
- m_log_category (log_category)
34
+ m_log_category (log_category),
35
+ m_message_on_completion (msg_on_completion)
34
36
{
35
37
this ->Log (strprintf (" %s started" , m_title));
36
38
m_start_t = GetTime<std::chrono::microseconds>();
37
39
}
38
40
39
41
~Timer ()
40
42
{
41
- this ->Log (strprintf (" %s completed" , m_title));
43
+ if (m_message_on_completion) {
44
+ this ->Log (strprintf (" %s completed" , m_title));
45
+ } else {
46
+ this ->Log (" completed" );
47
+ }
42
48
}
43
49
44
50
void Log (const std::string& msg)
@@ -74,14 +80,17 @@ class Timer
74
80
std::chrono::microseconds m_start_t {};
75
81
76
82
// ! Log prefix; usually the name of the function this was created in.
77
- const std::string m_prefix{} ;
83
+ const std::string m_prefix;
78
84
79
85
// ! A descriptive message of what is being timed.
80
- const std::string m_title{} ;
86
+ const std::string m_title;
81
87
82
88
// ! Forwarded on to LogPrint if specified - has the effect of only
83
89
// ! outputting the timing log when a particular debug= category is specified.
84
- const BCLog::LogFlags m_log_category{};
90
+ const BCLog::LogFlags m_log_category;
91
+
92
+ // ! Whether to output the message again on completion.
93
+ const bool m_message_on_completion;
85
94
};
86
95
87
96
} // namespace BCLog
0 commit comments