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.
This commit is contained in:
stickies-v
2026-01-26 18:48:08 +00:00
parent bb8e9e7c4c
commit 37cc2a2d95
33 changed files with 57 additions and 54 deletions

View File

@@ -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>

View File

@@ -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);

View File

@@ -4,21 +4,6 @@
#include <dbwrapper.h>
#include <logging.h>
#include <random.h>
#include <serialize.h>
#include <span.h>
#include <streams.h>
#include <util/fs.h>
#include <util/fs_helpers.h>
#include <util/obfuscation.h>
#include <util/strencodings.h>
#include <algorithm>
#include <cassert>
#include <cstdarg>
#include <cstdint>
#include <cstdio>
#include <leveldb/cache.h>
#include <leveldb/db.h>
#include <leveldb/env.h>
@@ -29,6 +14,22 @@
#include <leveldb/slice.h>
#include <leveldb/status.h>
#include <leveldb/write_batch.h>
#include <logging.h>
#include <random.h>
#include <serialize.h>
#include <span.h>
#include <streams.h>
#include <util/fs.h>
#include <util/fs_helpers.h>
#include <util/log.h>
#include <util/obfuscation.h>
#include <util/strencodings.h>
#include <algorithm>
#include <cassert>
#include <cstdarg>
#include <cstdint>
#include <cstdio>
#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;

View File

@@ -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)),

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -6,7 +6,6 @@
#include <coins.h>
#include <consensus/amount.h>
#include <logging.h>
#include <tinyformat.h>
#include <util/check.h>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -7,7 +7,6 @@
#define BITCOIN_SYNC_H
#ifdef DEBUG_LOCKCONTENTION
#include <logging.h>
#include <logging/timer.h>
#endif

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -4,7 +4,7 @@
#include <util/batchpriority.h>
#include <logging.h>
#include <util/log.h>
#include <util/syserror.h>
#include <string>

View File

@@ -5,8 +5,8 @@
#include <util/exception.h>
#include <logging.h>
#include <tinyformat.h>
#include <util/log.h>
#include <exception>
#include <iostream>

View File

@@ -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>

View File

@@ -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>

View File

@@ -11,6 +11,7 @@
#include <chrono>
#include <memory>
#include <span>
#include <string>
#include <unordered_map>

View File

@@ -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>

View File

@@ -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,

View File

@@ -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>