|
8 | 8 |
|
9 | 9 | #include <crypto/siphash.h> |
10 | 10 | #include <threadsafety.h> |
11 | | -#include <tinyformat.h> |
12 | 11 | #include <util/check.h> |
13 | 12 | #include <util/fs.h> |
14 | 13 | #include <util/log.h> // IWYU pragma: export |
15 | | -#include <util/string.h> |
16 | 14 | #include <util/time.h> |
17 | 15 |
|
18 | 16 | #include <atomic> |
| 17 | +#include <chrono> |
19 | 18 | #include <cstdint> |
20 | | -#include <cstring> |
21 | 19 | #include <functional> |
22 | 20 | #include <list> |
23 | 21 | #include <memory> |
24 | | -#include <mutex> |
25 | 22 | #include <string> |
26 | 23 | #include <unordered_map> |
27 | | -#include <unordered_set> |
28 | 24 | #include <vector> |
29 | 25 |
|
30 | 26 | static const bool DEFAULT_LOGTIMEMICROS = false; |
@@ -306,35 +302,4 @@ BCLog::Logger& LogInstance(); |
306 | 302 | /** Return true if str parses as a log category and set the flag */ |
307 | 303 | bool GetLogCategory(BCLog::LogFlags& flag, std::string_view str); |
308 | 304 |
|
309 | | -// Allow __func__ to be used in any context without warnings: |
310 | | -// NOLINTNEXTLINE(bugprone-lambda-function-name) |
311 | | -#define LogPrintLevel_(category, level, should_ratelimit, ...) util::log::g_dispatcher().Log(level, category, SourceLocation{__func__}, should_ratelimit, __VA_ARGS__) |
312 | | - |
313 | | -// Log unconditionally. Uses basic rate limiting to mitigate disk filling attacks. |
314 | | -// Be conservative when using functions that unconditionally log to debug.log! |
315 | | -// It should not be the case that an inbound peer can fill up a user's storage |
316 | | -// with debug.log entries. |
317 | | -#define LogInfo(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Info, /*should_ratelimit=*/true, __VA_ARGS__) |
318 | | -#define LogWarning(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Warning, /*should_ratelimit=*/true, __VA_ARGS__) |
319 | | -#define LogError(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Error, /*should_ratelimit=*/true, __VA_ARGS__) |
320 | | - |
321 | | -// Use a macro instead of a function for conditional logging to prevent |
322 | | -// evaluating arguments when logging for the category is not enabled. |
323 | | - |
324 | | -// Log by prefixing the output with the passed category name and severity level. This logs conditionally if |
325 | | -// the category is allowed. No rate limiting is applied, because users specifying -debug are assumed to be |
326 | | -// developers or power users who are aware that -debug may cause excessive disk usage due to logging. |
327 | | -#define detail_LogIfCategoryAndLevelEnabled(category, level, ...) \ |
328 | | - do { \ |
329 | | - if (LogAcceptCategory((category), (level))) { \ |
330 | | - bool rate_limit{level >= BCLog::Level::Info}; \ |
331 | | - Assume(!rate_limit);/*Only called with the levels below*/ \ |
332 | | - LogPrintLevel_(category, level, rate_limit, __VA_ARGS__); \ |
333 | | - } \ |
334 | | - } while (0) |
335 | | - |
336 | | -// Log conditionally, prefixing the output with the passed category name. |
337 | | -#define LogDebug(category, ...) detail_LogIfCategoryAndLevelEnabled(category, BCLog::Level::Debug, __VA_ARGS__) |
338 | | -#define LogTrace(category, ...) detail_LogIfCategoryAndLevelEnabled(category, BCLog::Level::Trace, __VA_ARGS__) |
339 | | - |
340 | 305 | #endif // BITCOIN_LOGGING_H |
0 commit comments