@@ -125,42 +125,31 @@ std::vector<CLogCategoryActive> ListActiveLogCategories();
125
125
/* * Return true if str parses as a log category and set the flag */
126
126
bool GetLogCategory (BCLog::LogFlags& flag, const std::string& str);
127
127
128
- /* * Get format string from VA_ARGS for error reporting */
129
- template <typename ... Args> std::string FormatStringFromLogArgs (const char *fmt, const Args&... args) { return fmt; }
130
-
131
- static inline void MarkUsed () {}
132
- template <typename T, typename ... Args> static inline void MarkUsed (const T& t, const Args&... args)
133
- {
134
- (void )t;
135
- MarkUsed (args...);
136
- }
137
-
138
128
// Be conservative when using LogPrintf/error or other things which
139
129
// unconditionally log to debug.log! It should not be the case that an inbound
140
130
// peer can fill up a user's disk with debug.log entries.
141
131
142
- #ifdef USE_COVERAGE
143
- #define LogPrintf (...) do { MarkUsed (__VA_ARGS__); } while (0 )
144
- #define LogPrint (category, ...) do { MarkUsed (__VA_ARGS__); } while (0 )
145
- #else
146
- #define LogPrintf (...) do { \
147
- if (g_logger->Enabled ()) { \
148
- std::string _log_msg_; /* Unlikely name to avoid shadowing variables */ \
149
- try { \
150
- _log_msg_ = tfm::format (__VA_ARGS__); \
151
- } catch (tinyformat::format_error &fmterr) { \
152
- /* Original format string will have newline so don't add one here */ \
153
- _log_msg_ = " Error \" " + std::string (fmterr.what ()) + " \" while formatting log message: " + FormatStringFromLogArgs (__VA_ARGS__); \
154
- } \
155
- g_logger->LogPrintStr (_log_msg_); \
156
- } \
157
- } while (0 )
158
-
159
- #define LogPrint (category, ...) do { \
160
- if (LogAcceptCategory ((category))) { \
161
- LogPrintf (__VA_ARGS__); \
162
- } \
163
- } while (0 )
164
- #endif
132
+ template <typename ... Args>
133
+ static inline void LogPrintf (const char * fmt, const Args&... args)
134
+ {
135
+ if (g_logger->Enabled ()) {
136
+ std::string log_msg;
137
+ try {
138
+ log_msg = tfm::format (fmt, args...);
139
+ } catch (tinyformat::format_error& fmterr) {
140
+ /* Original format string will have newline so don't add one here */
141
+ log_msg = " Error \" " + std::string (fmterr.what ()) + " \" while formatting log message: " + fmt;
142
+ }
143
+ g_logger->LogPrintStr (log_msg);
144
+ }
145
+ }
146
+
147
+ template <typename ... Args>
148
+ static inline void LogPrint (const BCLog::LogFlags& category, const Args&... args)
149
+ {
150
+ if (LogAcceptCategory ((category))) {
151
+ LogPrintf (args...);
152
+ }
153
+ }
165
154
166
155
#endif // BITCOIN_LOGGING_H
0 commit comments