logging: use util/log.h where possible
What changed, and why it matters
This is a routine code cleanup change. It swaps one internal logging header file for another, smaller one across many source files and fixes a few include-order style issues. There is no change to program behavior, no bug fix, and no security-relevant modification.
No action required. This is a non-security refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit replaces #include
Changed components
src/checkqueue.hsrc/coins.cppsrc/dbwrapper.cppsrc/flatfile.cppsrc/index/base.cppsrc/index/blockfilterindex.cppsrc/index/coinstatsindex.cppsrc/index/txindex.cppsrc/kernel/chainparams.cppsrc/kernel/coinstats.cppsrc/kernel/context.cppsrc/logging/timer.hsrc/node/blockstorage.cppsrc/node/chainstate.cppsrc/node/utxo_snapshot.cppsrc/policy/truc_policy.cppsrc/random.cppsrc/script/sigcache.cppsrc/signet.cppsrc/streams.hsrc/sync.cppsrc/sync.hsrc/txdb.cppsrc/txmempool.cppsrc/util/asmap.cppsrc/util/batchpriority.cppsrc/util/exception.cppsrc/util/fs_helpers.cppsrc/util/sock.cppsrc/util/sock.hsrc/util/thread.cppsrc/validation.cppsrc/validationinterface.cppInspect captured patch +52 / −49
diff --git a/src/checkqueue.h b/src/checkqueue.h
index 037023ee..5258d711 100644
--- a/src/checkqueue.h
+++ b/src/checkqueue.h
@@ -5,9 +5,9 @@
#ifndef BITCOIN_CHECKQUEUE_H
#define BITCOIN_CHECKQUEUE_H
-#include <logging.h>
#include <sync.h>
#include <tinyformat.h>
+#include <util/log.h>
#include <util/threadnames.h>
#include <algorithm>
diff --git a/src/coins.cpp b/src/coins.cpp
index a3bc369d..fc33c521 100644
--- a/src/coins.cpp
+++ b/src/coins.cpp
@@ -5,9 +5,9 @@
#include <coins.h>
#include <consensus/consensus.h>
-#include <logging.h>
#include <random.h>
#include <uint256.h>
+#include <util/log.h>
#include <util/trace.h>
TRACEPOINT_SEMAPHORE(utxocache, add);
diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp
index b3f08cb2..eb222078 100644
--- a/src/dbwrapper.cpp
+++ b/src/dbwrapper.cpp
@@ -4,6 +4,16 @@
#include <dbwrapper.h>
+#include <leveldb/cache.h>
+#include <leveldb/db.h>
+#include <leveldb/env.h>
+#include <leveldb/filter_policy.h>
+#include <leveldb/helpers/memenv/memenv.h>
+#include <leveldb/iterator.h>
+#include <leveldb/options.h>
+#include <leveldb/slice.h>
+#include <leveldb/status.h>
+#include <leveldb/write_batch.h>
#include <logging.h>
#include <random.h>
#include <serialize.h>
@@ -11,6 +21,7 @@
#include <streams.h>
#include <util/fs.h>
#include <util/fs_helpers.h>
+#include <util/log.h>
#include <util/obfuscation.h>
#include <util/strencodings.h>
@@ -19,16 +30,6 @@
#include <cstdarg>
#include <cstdint>
#include <cstdio>
-#include <leveldb/cache.h>
-#include <leveldb/db.h>
-#include <leveldb/env.h>
-#include <leveldb/filter_policy.h>
-#include <leveldb/helpers/memenv/memenv.h>
-#include <leveldb/iterator.h>
-#include <leveldb/options.h>
-#include <leveldb/slice.h>
-#include <leveldb/status.h>
-#include <leveldb/write_batch.h>
#include <memory>
#include <optional>
#include <utility>
@@ -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 140217b0..056fb9c1 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 <stdexcept>
-
#include <flatfile.h>
-#include <logging.h>
+
#include <tinyformat.h>
#include <util/fs_helpers.h>
+#include <util/log.h>
+
+#include <stdexcept>
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 7f77d13a..fba2f4f6 100644
--- a/src/index/base.cpp
+++ b/src/index/base.cpp
@@ -10,7 +10,6 @@
#include <interfaces/chain.h>
#include <interfaces/types.h>
#include <kernel/types.h>
-#include <logging.h>
#include <node/abort.h>
#include <node/blockstorage.h>
#include <node/context.h>
@@ -22,6 +21,7 @@
#include <uint256.h>
#include <undo.h>
#include <util/fs.h>
+#include <util/log.h>
#include <util/string.h>
#include <util/thread.h>
#include <util/threadinterrupt.h>
diff --git a/src/index/blockfilterindex.cpp b/src/index/blockfilterindex.cpp
index caf6d592..67fa1fab 100644
--- a/src/index/blockfilterindex.cpp
+++ b/src/index/blockfilterindex.cpp
@@ -14,7 +14,6 @@
#include <index/db_key.h>
#include <interfaces/chain.h>
#include <interfaces/types.h>
-#include <logging.h>
#include <serialize.h>
#include <streams.h>
#include <sync.h>
@@ -22,6 +21,7 @@
#include <util/check.h>
#include <util/fs.h>
#include <util/hasher.h>
+#include <util/log.h>
#include <util/syserror.h>
#include <cerrno>
diff --git a/src/index/coinstatsindex.cpp b/src/index/coinstatsindex.cpp
index 6be3db9a..319ffcad 100644
--- a/src/index/coinstatsindex.cpp
+++ b/src/index/coinstatsindex.cpp
@@ -17,7 +17,6 @@
#include <interfaces/chain.h>
#include <interfaces/types.h>
#include <kernel/coinstats.h>
-#include <logging.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <script/script.h>
@@ -26,6 +25,7 @@
#include <undo.h>
#include <util/check.h>
#include <util/fs.h>
+#include <util/log.h>
#include <validation.h>
#include <compare>
diff --git a/src/index/txindex.cpp b/src/index/txindex.cpp
index d7d8cb56..d0e88021 100644
--- a/src/index/txindex.cpp
+++ b/src/index/txindex.cpp
@@ -10,7 +10,6 @@
#include <index/base.h>
#include <index/disktxpos.h>
#include <interfaces/chain.h>
-#include <logging.h>
#include <node/blockstorage.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
@@ -18,6 +17,7 @@
#include <streams.h>
#include <uint256.h>
#include <util/fs.h>
+#include <util/log.h>
#include <validation.h>
#include <cassert>
diff --git a/src/kernel/chainparams.cpp b/src/kernel/chainparams.cpp
index 16ebffb9..79cf2ff7 100644
--- a/src/kernel/chainparams.cpp
+++ b/src/kernel/chainparams.cpp
@@ -12,13 +12,13 @@
#include <crypto/hex_base.h>
#include <hash.h>
#include <kernel/messagestartchars.h>
-#include <logging.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <script/interpreter.h>
#include <script/script.h>
#include <uint256.h>
#include <util/chaintype.h>
+#include <util/log.h>
#include <util/strencodings.h>
#include <algorithm>
diff --git a/src/kernel/coinstats.cpp b/src/kernel/coinstats.cpp
index 13c0bee8..d287ec4b 100644
--- a/src/kernel/coinstats.cpp
+++ b/src/kernel/coinstats.cpp
@@ -8,7 +8,6 @@
#include <coins.h>
#include <crypto/muhash.h>
#include <hash.h>
-#include <logging.h>
#include <node/blockstorage.h>
#include <primitives/transaction.h>
#include <script/script.h>
@@ -17,6 +16,7 @@
#include <sync.h>
#include <uint256.h>
#include <util/check.h>
+#include <util/log.h>
#include <util/overflow.h>
#include <validation.h>
diff --git a/src/kernel/context.cpp b/src/kernel/context.cpp
index e74f29cb..9148bf57 100644
--- a/src/kernel/context.cpp
+++ b/src/kernel/context.cpp
@@ -5,8 +5,8 @@
#include <kernel/context.h>
#include <crypto/sha256.h>
-#include <logging.h>
#include <random.h>
+#include <util/log.h>
#include <mutex>
#include <string>
diff --git a/src/logging/timer.h b/src/logging/timer.h
index 52a86e71..2b183822 100644
--- a/src/logging/timer.h
+++ b/src/logging/timer.h
@@ -6,7 +6,7 @@
#ifndef BITCOIN_LOGGING_TIMER_H
#define BITCOIN_LOGGING_TIMER_H
-#include <logging.h>
+#include <util/log.h>
#include <util/macros.h>
#include <util/time.h>
#include <util/types.h>
diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp
index 37bf1799..ddaaad19 100644
--- a/src/node/blockstorage.cpp
+++ b/src/node/blockstorage.cpp
@@ -16,7 +16,6 @@
#include <kernel/messagestartchars.h>
#include <kernel/notifications_interface.h>
#include <kernel/types.h>
-#include <logging.h>
#include <pow.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
@@ -31,6 +30,7 @@
#include <util/check.h>
#include <util/expected.h>
#include <util/fs.h>
+#include <util/log.h>
#include <util/obfuscation.h>
#include <util/overflow.h>
#include <util/result.h>
diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp
index 930d8431..b3e9753e 100644
--- a/src/node/chainstate.cpp
+++ b/src/node/chainstate.cpp
@@ -9,7 +9,6 @@
#include <coins.h>
#include <consensus/params.h>
#include <kernel/caches.h>
-#include <logging.h>
#include <node/blockstorage.h>
#include <sync.h>
#include <threadsafety.h>
@@ -17,6 +16,7 @@
#include <txdb.h>
#include <uint256.h>
#include <util/fs.h>
+#include <util/log.h>
#include <util/signalinterrupt.h>
#include <util/time.h>
#include <util/translation.h>
diff --git a/src/node/utxo_snapshot.cpp b/src/node/utxo_snapshot.cpp
index f11e979a..e5997b7b 100644
--- a/src/node/utxo_snapshot.cpp
+++ b/src/node/utxo_snapshot.cpp
@@ -4,12 +4,12 @@
#include <node/utxo_snapshot.h>
-#include <logging.h>
#include <streams.h>
#include <sync.h>
#include <tinyformat.h>
#include <uint256.h>
#include <util/fs.h>
+#include <util/log.h>
#include <validation.h>
#include <cassert>
diff --git a/src/policy/truc_policy.cpp b/src/policy/truc_policy.cpp
index 597d08f7..2ecb763e 100644
--- a/src/policy/truc_policy.cpp
+++ b/src/policy/truc_policy.cpp
@@ -6,7 +6,6 @@
#include <coins.h>
#include <consensus/amount.h>
-#include <logging.h>
#include <tinyformat.h>
#include <util/check.h>
diff --git a/src/random.cpp b/src/random.cpp
index aeaf6baa..f1c4bb86 100644
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -12,12 +12,12 @@
#include <crypto/chacha20.h>
#include <crypto/sha256.h>
#include <crypto/sha512.h>
-#include <logging.h>
#include <randomenv.h>
#include <span.h>
#include <support/allocators/secure.h>
#include <support/cleanse.h>
#include <sync.h>
+#include <util/log.h>
#include <util/time.h>
#include <array>
diff --git a/src/script/sigcache.cpp b/src/script/sigcache.cpp
index 77ffbabd..90d1c845 100644
--- a/src/script/sigcache.cpp
+++ b/src/script/sigcache.cpp
@@ -6,12 +6,12 @@
#include <script/sigcache.h>
#include <crypto/sha256.h>
-#include <logging.h>
#include <pubkey.h>
#include <random.h>
#include <script/interpreter.h>
#include <span.h>
#include <uint256.h>
+#include <util/log.h>
#include <mutex>
#include <shared_mutex>
diff --git a/src/signet.cpp b/src/signet.cpp
index d874ddc1..d0f8aa28 100644
--- a/src/signet.cpp
+++ b/src/signet.cpp
@@ -7,7 +7,6 @@
#include <consensus/merkle.h>
#include <consensus/params.h>
#include <consensus/validation.h>
-#include <logging.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <script/interpreter.h>
@@ -15,6 +14,7 @@
#include <streams.h>
#include <uint256.h>
#include <util/check.h>
+#include <util/log.h>
#include <algorithm>
#include <cstddef>
diff --git a/src/streams.h b/src/streams.h
index 466084e9..81dbf405 100644
--- a/src/streams.h
+++ b/src/streams.h
@@ -6,11 +6,11 @@
#ifndef BITCOIN_STREAMS_H
#define BITCOIN_STREAMS_H
-#include <logging.h>
#include <serialize.h>
#include <span.h>
#include <support/allocators/zeroafterfree.h>
#include <util/check.h>
+#include <util/log.h>
#include <util/obfuscation.h>
#include <util/overflow.h>
#include <util/syserror.h>
diff --git a/src/sync.cpp b/src/sync.cpp
index b661aad9..e59f86b9 100644
--- a/src/sync.cpp
+++ b/src/sync.cpp
@@ -4,8 +4,8 @@
#include <sync.h>
-#include <logging.h>
#include <tinyformat.h>
+#include <util/log.h>
#include <util/strencodings.h>
#include <util/threadnames.h>
diff --git a/src/sync.h b/src/sync.h
index 01e92e6e..548b51d9 100644
--- a/src/sync.h
+++ b/src/sync.h
@@ -7,7 +7,6 @@
#define BITCOIN_SYNC_H
#ifdef DEBUG_LOCKCONTENTION
-#include <logging.h>
#include <logging/timer.h>
#endif
diff --git a/src/txdb.cpp b/src/txdb.cpp
index 141c31c5..21f6eb93 100644
--- a/src/txdb.cpp
+++ b/src/txdb.cpp
@@ -7,11 +7,11 @@
#include <coins.h>
#include <dbwrapper.h>
-#include <logging.h>
#include <primitives/transaction.h>
#include <random.h>
#include <serialize.h>
#include <uint256.h>
+#include <util/log.h>
#include <util/vector.h>
#include <cassert>
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 2486270b..55c33276 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -11,13 +11,13 @@
#include <consensus/consensus.h>
#include <consensus/tx_verify.h>
#include <consensus/validation.h>
-#include <logging.h>
#include <policy/policy.h>
#include <policy/settings.h>
#include <random.h>
#include <tinyformat.h>
#include <util/check.h>
#include <util/feefrac.h>
+#include <util/log.h>
#include <util/moneystr.h>
#include <util/overflow.h>
#include <util/result.h>
diff --git a/src/util/asmap.cpp b/src/util/asmap.cpp
index 4d4ed4fe..f8b5a527 100644
--- a/src/util/asmap.cpp
+++ b/src/util/asmap.cpp
@@ -6,11 +6,11 @@
#include <clientversion.h>
#include <hash.h>
-#include <logging.h>
#include <serialize.h>
#include <streams.h>
#include <uint256.h>
#include <util/fs.h>
+#include <util/log.h>
#include <algorithm>
#include <bit>
diff --git a/src/util/batchpriority.cpp b/src/util/batchpriority.cpp
index 86abc011..e6bb43b4 100644
--- a/src/util/batchpriority.cpp
+++ b/src/util/batchpriority.cpp
@@ -4,7 +4,7 @@
#include <util/batchpriority.h>
-#include <logging.h>
+#include <util/log.h>
#include <util/syserror.h>
#include <string>
diff --git a/src/util/exception.cpp b/src/util/exception.cpp
index a4421226..cd2bd231 100644
--- a/src/util/exception.cpp
+++ b/src/util/exception.cpp
@@ -5,8 +5,8 @@
#include <util/exception.h>
-#include <logging.h>
#include <tinyformat.h>
+#include <util/log.h>
#include <exception>
#include <iostream>
diff --git a/src/util/fs_helpers.cpp b/src/util/fs_helpers.cpp
index 98646c02..e7780d74 100644
--- a/src/util/fs_helpers.cpp
+++ b/src/util/fs_helpers.cpp
@@ -3,13 +3,13 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <util/fs_helpers.h>
-
#include <bitcoin-build-config.h> // IWYU pragma: keep
-#include <logging.h>
+#include <util/fs_helpers.h>
+
#include <sync.h>
#include <util/fs.h>
+#include <util/log.h>
#include <util/syserror.h>
#include <cerrno>
diff --git a/src/util/sock.cpp b/src/util/sock.cpp
index ba822a0e..f13406eb 100644
--- a/src/util/sock.cpp
+++ b/src/util/sock.cpp
@@ -2,11 +2,13 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#include <util/sock.h>
+
#include <common/system.h>
#include <compat/compat.h>
-#include <logging.h>
+#include <span.h>
#include <tinyformat.h>
-#include <util/sock.h>
+#include <util/log.h>
#include <util/syserror.h>
#include <util/threadinterrupt.h>
#include <util/time.h>
diff --git a/src/util/sock.h b/src/util/sock.h
index 69ec1b8e..8c51b8ea 100644
--- a/src/util/sock.h
+++ b/src/util/sock.h
@@ -11,6 +11,7 @@
#include <chrono>
#include <memory>
+#include <span>
#include <string>
#include <unordered_map>
diff --git a/src/util/thread.cpp b/src/util/thread.cpp
index 7f8fa20a..0fde73c4 100644
--- a/src/util/thread.cpp
+++ b/src/util/thread.cpp
@@ -4,8 +4,8 @@
#include <util/thread.h>
-#include <logging.h>
#include <util/exception.h>
+#include <util/log.h>
#include <util/threadnames.h>
#include <exception>
diff --git a/src/validation.cpp b/src/validation.cpp
index f2819695..c200c3d6 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -28,7 +28,6 @@
#include <kernel/notifications_interface.h>
#include <kernel/types.h>
#include <kernel/warning.h>
-#include <logging.h>
#include <logging/timer.h>
#include <node/blockstorage.h>
#include <node/utxo_snapshot.h>
@@ -53,6 +52,7 @@
#include <util/fs.h>
#include <util/fs_helpers.h>
#include <util/hasher.h>
+#include <util/log.h>
#include <util/moneystr.h>
#include <util/rbf.h>
#include <util/result.h>
@@ -2870,7 +2870,7 @@ static void UpdateTipLog(
AssertLockHeld(::cs_main);
// Disable rate limiting in LogPrintLevel_ so this source location may log during IBD.
- LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Info, /*should_ratelimit=*/false, "%s%s: new best=%s height=%d version=0x%08x log2_work=%f tx=%lu date='%s' progress=%f cache=%.1fMiB(%utxo)%s\n",
+ LogPrintLevel_(BCLog::LogFlags::ALL, util::log::Level::Info, /*should_ratelimit=*/false, "%s%s: new best=%s height=%d version=0x%08x log2_work=%f tx=%lu date='%s' progress=%f cache=%.1fMiB(%utxo)%s\n",
prefix, func_name,
tip->GetBlockHash().ToString(), tip->nHeight, tip->nVersion,
log(tip->nChainWork.getdouble()) / log(2.0), tip->m_chain_tx_count,
diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp
index 586d29f4..c7be6abc 100644
--- a/src/validationinterface.cpp
+++ b/src/validationinterface.cpp
@@ -10,10 +10,10 @@
#include <kernel/mempool_entry.h>
#include <kernel/mempool_removal_reason.h>
#include <kernel/types.h>
-#include <logging.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <util/check.h>
+#include <util/log.h>
#include <util/task_runner.h>
#include <future>
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.