From f5233f7e9827f8dd23414c7fcf49298420f9fc42 Mon Sep 17 00:00:00 2001 From: stickies-v Date: Tue, 16 Dec 2025 15:37:21 +0000 Subject: [PATCH 1/6] move-only: Move SourceLocation to util/log.h Introduce util/log.h as a lightweight header for code that only needs to emit log messages. Move SourceLocation into this header so log-emitting code no longer needs to include logging.h and depend on the full log management API. This is a move-only change and the first change of several changes that separate log generation from log handling. It also applies clang-format suggestions to the moved code. Review with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space Co-authored-by: Ryan Ofsky --- src/logging.h | 21 +-------------------- src/util/log.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 src/util/log.h diff --git a/src/logging.h b/src/logging.h index 2ab21071a06..2b4b657dc9e 100644 --- a/src/logging.h +++ b/src/logging.h @@ -11,6 +11,7 @@ #include #include #include +#include // IWYU pragma: export #include #include @@ -37,26 +38,6 @@ extern const char * const DEFAULT_DEBUGLOGFILE; extern bool fLogIPs; -/// Like std::source_location, but allowing to override the function name. -class SourceLocation -{ -public: - /// The func argument must be constructed from the C++11 __func__ macro. - /// Ref: https://en.cppreference.com/w/cpp/language/function.html#func - /// Non-static string literals are not supported. - SourceLocation(const char* func, - std::source_location loc = std::source_location::current()) - : m_func{func}, m_loc{loc} {} - - std::string_view file_name() const { return m_loc.file_name(); } - std::uint_least32_t line() const { return m_loc.line(); } - std::string_view function_name_short() const { return m_func; } - -private: - std::string_view m_func; - std::source_location m_loc; -}; - struct SourceLocationEqual { bool operator()(const SourceLocation& lhs, const SourceLocation& rhs) const noexcept { diff --git a/src/util/log.h b/src/util/log.h new file mode 100644 index 00000000000..7ad548631a7 --- /dev/null +++ b/src/util/log.h @@ -0,0 +1,32 @@ +// Copyright (c) The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_UTIL_LOG_H +#define BITCOIN_UTIL_LOG_H + +#include +#include +#include + +/// Like std::source_location, but allowing to override the function name. +class SourceLocation +{ +public: + /// The func argument must be constructed from the C++11 __func__ macro. + /// Ref: https://en.cppreference.com/w/cpp/language/function.html#func + /// Non-static string literals are not supported. + SourceLocation(const char* func, + std::source_location loc = std::source_location::current()) + : m_func{func}, m_loc{loc} {} + + std::string_view file_name() const { return m_loc.file_name(); } + std::uint_least32_t line() const { return m_loc.line(); } + std::string_view function_name_short() const { return m_func; } + +private: + std::string_view m_func; + std::source_location m_loc; +}; + +#endif // BITCOIN_UTIL_LOG_H From 56d113cab0347a768daabccdfd76583e6b272dc4 Mon Sep 17 00:00:00 2001 From: stickies-v Date: Mon, 19 Jan 2026 15:38:49 +0000 Subject: [PATCH 2/6] move-only: move logging categories to logging/categories.h Logging categories are currently shared between node and kernel. This separation allows future commits to completely remove kernel's dependency on logging.h. Also applies clang-format suggestions to the moved code. Review with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space Co-authored-by: Ryan Ofsky --- src/logging.h | 39 +---------------------------- src/logging/categories.h | 54 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 38 deletions(-) create mode 100644 src/logging/categories.h diff --git a/src/logging.h b/src/logging.h index 2b4b657dc9e..18eb2c61028 100644 --- a/src/logging.h +++ b/src/logging.h @@ -7,6 +7,7 @@ #define BITCOIN_LOGGING_H #include +#include // IWYU pragma: export #include #include #include @@ -62,44 +63,6 @@ struct LogCategory { }; namespace BCLog { - using CategoryMask = uint64_t; - enum LogFlags : CategoryMask { - NONE = CategoryMask{0}, - NET = (CategoryMask{1} << 0), - TOR = (CategoryMask{1} << 1), - MEMPOOL = (CategoryMask{1} << 2), - HTTP = (CategoryMask{1} << 3), - BENCH = (CategoryMask{1} << 4), - ZMQ = (CategoryMask{1} << 5), - WALLETDB = (CategoryMask{1} << 6), - RPC = (CategoryMask{1} << 7), - ESTIMATEFEE = (CategoryMask{1} << 8), - ADDRMAN = (CategoryMask{1} << 9), - SELECTCOINS = (CategoryMask{1} << 10), - REINDEX = (CategoryMask{1} << 11), - CMPCTBLOCK = (CategoryMask{1} << 12), - RAND = (CategoryMask{1} << 13), - PRUNE = (CategoryMask{1} << 14), - PROXY = (CategoryMask{1} << 15), - MEMPOOLREJ = (CategoryMask{1} << 16), - LIBEVENT = (CategoryMask{1} << 17), - COINDB = (CategoryMask{1} << 18), - QT = (CategoryMask{1} << 19), - LEVELDB = (CategoryMask{1} << 20), - VALIDATION = (CategoryMask{1} << 21), - I2P = (CategoryMask{1} << 22), - IPC = (CategoryMask{1} << 23), -#ifdef DEBUG_LOCKCONTENTION - LOCK = (CategoryMask{1} << 24), -#endif - BLOCKSTORAGE = (CategoryMask{1} << 25), - TXRECONCILIATION = (CategoryMask{1} << 26), - SCAN = (CategoryMask{1} << 27), - TXPACKAGES = (CategoryMask{1} << 28), - KERNEL = (CategoryMask{1} << 29), - PRIVBROADCAST = (CategoryMask{1} << 30), - ALL = ~NONE, - }; enum class Level { Trace = 0, // High-volume or detailed logging for development/debugging Debug, // Reasonably noisy logging, but still usable in production diff --git a/src/logging/categories.h b/src/logging/categories.h new file mode 100644 index 00000000000..dff00adaf1a --- /dev/null +++ b/src/logging/categories.h @@ -0,0 +1,54 @@ +// Copyright (c) The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_LOGGING_CATEGORIES_H +#define BITCOIN_LOGGING_CATEGORIES_H + +#include + +namespace BCLog { + +using CategoryMask = uint64_t; + +enum LogFlags : CategoryMask { + NONE = CategoryMask{0}, + NET = (CategoryMask{1} << 0), + TOR = (CategoryMask{1} << 1), + MEMPOOL = (CategoryMask{1} << 2), + HTTP = (CategoryMask{1} << 3), + BENCH = (CategoryMask{1} << 4), + ZMQ = (CategoryMask{1} << 5), + WALLETDB = (CategoryMask{1} << 6), + RPC = (CategoryMask{1} << 7), + ESTIMATEFEE = (CategoryMask{1} << 8), + ADDRMAN = (CategoryMask{1} << 9), + SELECTCOINS = (CategoryMask{1} << 10), + REINDEX = (CategoryMask{1} << 11), + CMPCTBLOCK = (CategoryMask{1} << 12), + RAND = (CategoryMask{1} << 13), + PRUNE = (CategoryMask{1} << 14), + PROXY = (CategoryMask{1} << 15), + MEMPOOLREJ = (CategoryMask{1} << 16), + LIBEVENT = (CategoryMask{1} << 17), + COINDB = (CategoryMask{1} << 18), + QT = (CategoryMask{1} << 19), + LEVELDB = (CategoryMask{1} << 20), + VALIDATION = (CategoryMask{1} << 21), + I2P = (CategoryMask{1} << 22), + IPC = (CategoryMask{1} << 23), +#ifdef DEBUG_LOCKCONTENTION + LOCK = (CategoryMask{1} << 24), +#endif + BLOCKSTORAGE = (CategoryMask{1} << 25), + TXRECONCILIATION = (CategoryMask{1} << 26), + SCAN = (CategoryMask{1} << 27), + TXPACKAGES = (CategoryMask{1} << 28), + KERNEL = (CategoryMask{1} << 29), + PRIVBROADCAST = (CategoryMask{1} << 30), + ALL = ~NONE, +}; + +} // namespace BCLog + +#endif // BITCOIN_LOGGING_CATEGORIES_H From 94c0adf4e857f3c58a7ab813eb33b83635101d75 Mon Sep 17 00:00:00 2001 From: stickies-v Date: Wed, 21 Jan 2026 18:11:38 +0000 Subject: [PATCH 3/6] move-onlyish: Move logging levels to util/log.h This is not strictly move-only because BCLog::Level is now defined as a type alias for util::log::Level; Review with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space Co-authored-by: Ryan Ofsky --- src/logging.h | 7 ------- src/util/log.h | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/logging.h b/src/logging.h index 18eb2c61028..f9fddd5e3f2 100644 --- a/src/logging.h +++ b/src/logging.h @@ -63,13 +63,6 @@ struct LogCategory { }; namespace BCLog { - enum class Level { - Trace = 0, // High-volume or detailed logging for development/debugging - Debug, // Reasonably noisy logging, but still usable in production - Info, // Default - Warning, - Error, - }; constexpr auto DEFAULT_LOG_LEVEL{Level::Debug}; constexpr size_t DEFAULT_MAX_LOG_BUFFER{1'000'000}; // buffer up to 1MB of log data prior to StartLogging constexpr uint64_t RATELIMIT_MAX_BYTES{1024 * 1024}; // maximum number of bytes per source location that can be logged within the RATELIMIT_WINDOW diff --git a/src/util/log.h b/src/util/log.h index 7ad548631a7..f1d3bb26afd 100644 --- a/src/util/log.h +++ b/src/util/log.h @@ -29,4 +29,18 @@ private: std::source_location m_loc; }; +namespace util::log { +enum class Level { + Trace = 0, // High-volume or detailed logging for development/debugging + Debug, // Reasonably noisy logging, but still usable in production + Info, // Default + Warning, + Error, +}; +} // namespace util::log + +namespace BCLog { +//! Alias for compatibility. Prefer util::log::Level over BCLog::Level in new code. +using Level = util::log::Level; +} // namespace BCLog #endif // BITCOIN_UTIL_LOG_H From 001f0a428e3aa3f46aad373684beb3282bffb2c0 Mon Sep 17 00:00:00 2001 From: stickies-v Date: Tue, 20 Jan 2026 17:50:59 +0000 Subject: [PATCH 4/6] move-only: Move logging macros to util/log.h Move logging macros to util/log.h so the entire codebase can use the same macros. Review with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space Co-authored-by: Ryan Ofsky --- src/logging.h | 31 ------------------------------- src/util/log.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/logging.h b/src/logging.h index f9fddd5e3f2..d41a33bc3af 100644 --- a/src/logging.h +++ b/src/logging.h @@ -318,35 +318,4 @@ inline void LogPrintFormatInternal(SourceLocation&& source_loc, BCLog::LogFlags } } -// Allow __func__ to be used in any context without warnings: -// NOLINTNEXTLINE(bugprone-lambda-function-name) -#define LogPrintLevel_(category, level, should_ratelimit, ...) LogPrintFormatInternal(SourceLocation{__func__}, category, level, should_ratelimit, __VA_ARGS__) - -// Log unconditionally. Uses basic rate limiting to mitigate disk filling attacks. -// Be conservative when using functions that unconditionally log to debug.log! -// It should not be the case that an inbound peer can fill up a user's storage -// with debug.log entries. -#define LogInfo(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Info, /*should_ratelimit=*/true, __VA_ARGS__) -#define LogWarning(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Warning, /*should_ratelimit=*/true, __VA_ARGS__) -#define LogError(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Error, /*should_ratelimit=*/true, __VA_ARGS__) - -// Use a macro instead of a function for conditional logging to prevent -// evaluating arguments when logging for the category is not enabled. - -// Log by prefixing the output with the passed category name and severity level. This logs conditionally if -// the category is allowed. No rate limiting is applied, because users specifying -debug are assumed to be -// developers or power users who are aware that -debug may cause excessive disk usage due to logging. -#define detail_LogIfCategoryAndLevelEnabled(category, level, ...) \ - do { \ - if (LogAcceptCategory((category), (level))) { \ - bool rate_limit{level >= BCLog::Level::Info}; \ - Assume(!rate_limit);/*Only called with the levels below*/ \ - LogPrintLevel_(category, level, rate_limit, __VA_ARGS__); \ - } \ - } while (0) - -// Log conditionally, prefixing the output with the passed category name. -#define LogDebug(category, ...) detail_LogIfCategoryAndLevelEnabled(category, BCLog::Level::Debug, __VA_ARGS__) -#define LogTrace(category, ...) detail_LogIfCategoryAndLevelEnabled(category, BCLog::Level::Trace, __VA_ARGS__) - #endif // BITCOIN_LOGGING_H diff --git a/src/util/log.h b/src/util/log.h index f1d3bb26afd..ef5cbf14ec5 100644 --- a/src/util/log.h +++ b/src/util/log.h @@ -43,4 +43,36 @@ namespace BCLog { //! Alias for compatibility. Prefer util::log::Level over BCLog::Level in new code. using Level = util::log::Level; } // namespace BCLog + +// Allow __func__ to be used in any context without warnings: +// NOLINTNEXTLINE(bugprone-lambda-function-name) +#define LogPrintLevel_(category, level, should_ratelimit, ...) LogPrintFormatInternal(SourceLocation{__func__}, category, level, should_ratelimit, __VA_ARGS__) + +// Log unconditionally. Uses basic rate limiting to mitigate disk filling attacks. +// Be conservative when using functions that unconditionally log to debug.log! +// It should not be the case that an inbound peer can fill up a user's storage +// with debug.log entries. +#define LogInfo(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Info, /*should_ratelimit=*/true, __VA_ARGS__) +#define LogWarning(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Warning, /*should_ratelimit=*/true, __VA_ARGS__) +#define LogError(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Error, /*should_ratelimit=*/true, __VA_ARGS__) + +// Use a macro instead of a function for conditional logging to prevent +// evaluating arguments when logging for the category is not enabled. + +// Log by prefixing the output with the passed category name and severity level. This logs conditionally if +// the category is allowed. No rate limiting is applied, because users specifying -debug are assumed to be +// developers or power users who are aware that -debug may cause excessive disk usage due to logging. +#define detail_LogIfCategoryAndLevelEnabled(category, level, ...) \ + do { \ + if (LogAcceptCategory((category), (level))) { \ + bool rate_limit{level >= BCLog::Level::Info}; \ + Assume(!rate_limit); /*Only called with the levels below*/ \ + LogPrintLevel_(category, level, rate_limit, __VA_ARGS__); \ + } \ + } while (0) + +// Log conditionally, prefixing the output with the passed category name. +#define LogDebug(category, ...) detail_LogIfCategoryAndLevelEnabled(category, BCLog::Level::Debug, __VA_ARGS__) +#define LogTrace(category, ...) detail_LogIfCategoryAndLevelEnabled(category, BCLog::Level::Trace, __VA_ARGS__) + #endif // BITCOIN_UTIL_LOG_H From bb8e9e7c4c8d70914d0878a0d7c6a1371dae23c0 Mon Sep 17 00:00:00 2001 From: stickies-v Date: Tue, 16 Dec 2025 15:37:21 +0000 Subject: [PATCH 5/6] logging: Move message formatting to util/log.h With this change, callers can use util/log.h to emit log messages and do not need to include the full logging implementation in logging.h. There's a potential performance impact with this change from an extra `strprintf` call in log statements where `Logger::WillLogCategoryLevel` returns true but `Logger::Enabled` returns false. This happens when bitcoind is run with `-noprinttoconsole -nodebuglogfile` options. For background, log macro arguments are supposed to be evaluated when `Logger::WillLogCategoryLevel` returns true, even if log output is not enabled. Changing this behavior would be reasonable but needs consideration in a separate PR since not evaluating arguments in log statements has the potential to change non-logging behavior. The extra `strprintf` call could have been avoided by expanding this change and making the `ShouldLog()` function return a tri-state DO_LOG / DO_NOT_LOG / DO_NOT_LOG_ONLY_EVALUATE_ARGS value instead of a bool, but this complexity did not seem warranted. Review with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space Co-authored-by: Ryan Ofsky --- src/logging.cpp | 13 +++++++++++++ src/logging.h | 19 ------------------- src/util/log.h | 42 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 54 insertions(+), 20 deletions(-) diff --git a/src/logging.cpp b/src/logging.cpp index 1c3e30e9807..df6946d6611 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -602,3 +602,16 @@ bool BCLog::Logger::SetCategoryLogLevel(std::string_view category_str, std::stri m_category_log_levels[flag] = level.value(); return true; } + +bool util::log::ShouldLog(Category category, Level level) +{ + return LogInstance().WillLogCategoryLevel(static_cast(category), level); +} + +void util::log::Log(util::log::Entry entry) +{ + BCLog::Logger& logger{LogInstance()}; + if (logger.Enabled()) { + logger.LogPrintStr(std::move(entry.message), std::move(entry.source_loc), static_cast(entry.category), entry.level, entry.should_ratelimit); + } +} diff --git a/src/logging.h b/src/logging.h index d41a33bc3af..e21495015b6 100644 --- a/src/logging.h +++ b/src/logging.h @@ -9,8 +9,6 @@ #include #include // IWYU pragma: export #include -#include -#include #include #include // IWYU pragma: export #include @@ -22,11 +20,8 @@ #include #include #include -#include -#include #include #include -#include #include static const bool DEFAULT_LOGTIMEMICROS = false; @@ -304,18 +299,4 @@ static inline bool LogAcceptCategory(BCLog::LogFlags category, BCLog::Level leve /** Return true if str parses as a log category and set the flag */ bool GetLogCategory(BCLog::LogFlags& flag, std::string_view str); -template -inline void LogPrintFormatInternal(SourceLocation&& source_loc, BCLog::LogFlags flag, BCLog::Level level, bool should_ratelimit, util::ConstevalFormatString fmt, const Args&... args) -{ - if (LogInstance().Enabled()) { - std::string log_msg; - try { - log_msg = tfm::format(fmt, args...); - } catch (tinyformat::format_error& fmterr) { - log_msg = "Error \"" + std::string{fmterr.what()} + "\" while formatting log message: " + fmt.fmt; - } - LogInstance().LogPrintStr(log_msg, std::move(source_loc), flag, level, should_ratelimit); - } -} - #endif // BITCOIN_LOGGING_H diff --git a/src/util/log.h b/src/util/log.h index ef5cbf14ec5..aae23f0df1e 100644 --- a/src/util/log.h +++ b/src/util/log.h @@ -5,8 +5,13 @@ #ifndef BITCOIN_UTIL_LOG_H #define BITCOIN_UTIL_LOG_H +#include // IWYU pragma: export +#include +#include + #include #include +#include #include /// Like std::source_location, but allowing to override the function name. @@ -30,6 +35,9 @@ private: }; namespace util::log { +/** Opaque to util::log; interpreted by consumers (e.g., BCLog::LogFlags). */ +using Category = uint64_t; + enum class Level { Trace = 0, // High-volume or detailed logging for development/debugging Debug, // Reasonably noisy logging, but still usable in production @@ -37,6 +45,21 @@ enum class Level { Warning, Error, }; + +struct Entry { + Category category; + Level level; + bool should_ratelimit{false}; //!< Hint for consumers if this entry should be ratelimited + SourceLocation source_loc; + std::string message; +}; + +/** Return whether messages with specified category and level should be logged. Applications using + * the logging library need to provide this. */ +bool ShouldLog(Category category, Level level); + +/** Send message to be logged. Applications using the logging library need to provide this. */ +void Log(Entry entry); } // namespace util::log namespace BCLog { @@ -44,6 +67,23 @@ namespace BCLog { using Level = util::log::Level; } // namespace BCLog +template +inline void LogPrintFormatInternal(SourceLocation&& source_loc, BCLog::LogFlags flag, BCLog::Level level, bool should_ratelimit, util::ConstevalFormatString fmt, const Args&... args) +{ + std::string log_msg; + try { + log_msg = tfm::format(fmt, args...); + } catch (tinyformat::format_error& fmterr) { + log_msg = "Error \"" + std::string{fmterr.what()} + "\" while formatting log message: " + fmt.fmt; + } + util::log::Log(util::log::Entry{ + .category = flag, + .level = level, + .should_ratelimit = should_ratelimit, + .source_loc = std::move(source_loc), + .message = std::move(log_msg)}); +} + // Allow __func__ to be used in any context without warnings: // NOLINTNEXTLINE(bugprone-lambda-function-name) #define LogPrintLevel_(category, level, should_ratelimit, ...) LogPrintFormatInternal(SourceLocation{__func__}, category, level, should_ratelimit, __VA_ARGS__) @@ -64,7 +104,7 @@ using Level = util::log::Level; // developers or power users who are aware that -debug may cause excessive disk usage due to logging. #define detail_LogIfCategoryAndLevelEnabled(category, level, ...) \ do { \ - if (LogAcceptCategory((category), (level))) { \ + if (util::log::ShouldLog((category), (level))) { \ bool rate_limit{level >= BCLog::Level::Info}; \ Assume(!rate_limit); /*Only called with the levels below*/ \ LogPrintLevel_(category, level, rate_limit, __VA_ARGS__); \ From 37cc2a2d953c072a236b657bfd7de5167092a47a Mon Sep 17 00:00:00 2001 From: stickies-v Date: Mon, 26 Jan 2026 18:48:08 +0000 Subject: [PATCH 6/6] logging: use util/log.h where possible Preparation for a future commit where kernel's dependency on logging.cpp is removed completely. Replace usage of logging\.h with util/log\.h where it suffices, and fix wrong includes according to iwyu. --- src/checkqueue.h | 2 +- src/coins.cpp | 2 +- src/dbwrapper.cpp | 35 +++++++++++++++++----------------- src/flatfile.cpp | 7 ++++--- src/index/base.cpp | 2 +- src/index/blockfilterindex.cpp | 2 +- src/index/coinstatsindex.cpp | 2 +- src/index/txindex.cpp | 2 +- src/kernel/chainparams.cpp | 2 +- src/kernel/coinstats.cpp | 2 +- src/kernel/context.cpp | 2 +- src/logging/timer.h | 2 +- src/node/blockstorage.cpp | 2 +- src/node/chainstate.cpp | 2 +- src/node/utxo_snapshot.cpp | 2 +- src/policy/truc_policy.cpp | 1 - src/random.cpp | 2 +- src/script/sigcache.cpp | 2 +- src/signet.cpp | 2 +- src/streams.h | 2 +- src/sync.cpp | 2 +- src/sync.h | 1 - src/txdb.cpp | 2 +- src/txmempool.cpp | 2 +- src/util/asmap.cpp | 2 +- src/util/batchpriority.cpp | 2 +- src/util/exception.cpp | 2 +- src/util/fs_helpers.cpp | 6 +++--- src/util/sock.cpp | 6 ++++-- src/util/sock.h | 1 + src/util/thread.cpp | 2 +- src/validation.cpp | 4 ++-- src/validationinterface.cpp | 2 +- 33 files changed, 57 insertions(+), 54 deletions(-) diff --git a/src/checkqueue.h b/src/checkqueue.h index 037023ee3a2..5258d7113e6 100644 --- a/src/checkqueue.h +++ b/src/checkqueue.h @@ -5,9 +5,9 @@ #ifndef BITCOIN_CHECKQUEUE_H #define BITCOIN_CHECKQUEUE_H -#include #include #include +#include #include #include diff --git a/src/coins.cpp b/src/coins.cpp index a3bc369de30..fc33c521617 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -5,9 +5,9 @@ #include #include -#include #include #include +#include #include TRACEPOINT_SEMAPHORE(utxocache, add); diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp index b3f08cb20d6..eb222078b5e 100644 --- a/src/dbwrapper.cpp +++ b/src/dbwrapper.cpp @@ -4,21 +4,6 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include #include #include #include @@ -29,6 +14,22 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include #include #include #include @@ -57,7 +58,7 @@ public: // This code is adapted from posix_logger.h, which is why it is using vsprintf. // Please do not do this in normal code void Logv(const char * format, va_list ap) override { - if (!LogAcceptCategory(BCLog::LEVELDB, BCLog::Level::Debug)) { + if (!LogAcceptCategory(BCLog::LEVELDB, util::log::Level::Debug)) { return; } char buffer[500]; @@ -276,7 +277,7 @@ CDBWrapper::~CDBWrapper() void CDBWrapper::WriteBatch(CDBBatch& batch, bool fSync) { - const bool log_memory = LogAcceptCategory(BCLog::LEVELDB, BCLog::Level::Debug); + const bool log_memory = LogAcceptCategory(BCLog::LEVELDB, util::log::Level::Debug); double mem_before = 0; if (log_memory) { mem_before = DynamicMemoryUsage() / 1024.0 / 1024; diff --git a/src/flatfile.cpp b/src/flatfile.cpp index 140217b0603..056fb9c1f92 100644 --- a/src/flatfile.cpp +++ b/src/flatfile.cpp @@ -3,12 +3,13 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include - #include -#include + #include #include +#include + +#include FlatFileSeq::FlatFileSeq(fs::path dir, const char* prefix, size_t chunk_size) : m_dir(std::move(dir)), diff --git a/src/index/base.cpp b/src/index/base.cpp index 7f77d13a574..fba2f4f6c10 100644 --- a/src/index/base.cpp +++ b/src/index/base.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -22,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/src/index/blockfilterindex.cpp b/src/index/blockfilterindex.cpp index caf6d592e7e..67fa1fab318 100644 --- a/src/index/blockfilterindex.cpp +++ b/src/index/blockfilterindex.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -22,6 +21,7 @@ #include #include #include +#include #include #include diff --git a/src/index/coinstatsindex.cpp b/src/index/coinstatsindex.cpp index 6be3db9a897..319ffcadc63 100644 --- a/src/index/coinstatsindex.cpp +++ b/src/index/coinstatsindex.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include