Skip to content

Commit face812

Browse files
author
MarcoFalke
committed
log: [refactor] Use info level for init logs
This refactor does not change behavior.
1 parent fa18376 commit face812

27 files changed

+106
-102
lines changed

src/banman.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void BanMan::LoadBanlist()
3939
LogDebug(BCLog::NET, "Loaded %d banned node addresses/subnets %dms\n", m_banned.size(),
4040
Ticks<std::chrono::milliseconds>(SteadyClock::now() - start));
4141
} else {
42-
LogPrintf("Recreating the banlist database\n");
42+
LogInfo("Recreating the banlist database");
4343
m_banned = {};
4444
m_is_dirty = true;
4545
}

src/chainparams.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ void ReadRegTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& opti
9696
if (vDeploymentParams[0] == VersionBitsDeploymentInfo[j].name) {
9797
options.version_bits_parameters[Consensus::DeploymentPos(j)] = vbparams;
9898
found = true;
99-
LogPrintf("Setting version bits activation parameters for %s to start=%ld, timeout=%ld, min_activation_height=%d\n", vDeploymentParams[0], vbparams.start_time, vbparams.timeout, vbparams.min_activation_height);
99+
LogInfo("Setting version bits activation parameters for %s to start=%ld, timeout=%ld, min_activation_height=%d",
100+
vDeploymentParams[0], vbparams.start_time, vbparams.timeout, vbparams.min_activation_height);
100101
break;
101102
}
102103
}

src/dbwrapper.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,25 +228,25 @@ CDBWrapper::CDBWrapper(const DBParams& params)
228228
DBContext().options.env = DBContext().penv;
229229
} else {
230230
if (params.wipe_data) {
231-
LogPrintf("Wiping LevelDB in %s\n", fs::PathToString(params.path));
231+
LogInfo("Wiping LevelDB in %s", fs::PathToString(params.path));
232232
leveldb::Status result = leveldb::DestroyDB(fs::PathToString(params.path), DBContext().options);
233233
HandleError(result);
234234
}
235235
TryCreateDirectories(params.path);
236-
LogPrintf("Opening LevelDB in %s\n", fs::PathToString(params.path));
236+
LogInfo("Opening LevelDB in %s", fs::PathToString(params.path));
237237
}
238238
// PathToString() return value is safe to pass to leveldb open function,
239239
// because on POSIX leveldb passes the byte string directly to ::open(), and
240240
// on Windows it converts from UTF-8 to UTF-16 before calling ::CreateFileW
241241
// (see env_posix.cc and env_windows.cc).
242242
leveldb::Status status = leveldb::DB::Open(DBContext().options, fs::PathToString(params.path), &DBContext().pdb);
243243
HandleError(status);
244-
LogPrintf("Opened LevelDB successfully\n");
244+
LogInfo("Opened LevelDB successfully");
245245

246246
if (params.options.force_compact) {
247-
LogPrintf("Starting database compaction of %s\n", fs::PathToString(params.path));
247+
LogInfo("Starting database compaction of %s", fs::PathToString(params.path));
248248
DBContext().pdb->CompactRange(nullptr, nullptr);
249-
LogPrintf("Finished database compaction of %s\n", fs::PathToString(params.path));
249+
LogInfo("Finished database compaction of %s", fs::PathToString(params.path));
250250
}
251251

252252
assert(!m_obfuscation); // Needed for unobfuscated Read()/Write() below

src/dummywallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class DummyWalletInit : public WalletInitInterface {
2121
bool HasWalletSupport() const override {return false;}
2222
void AddWalletOptions(ArgsManager& argsman) const override;
2323
bool ParameterInteraction() const override {return true;}
24-
void Construct(node::NodeContext& node) const override {LogPrintf("No wallet support compiled in!\n");}
24+
void Construct(node::NodeContext& node) const override { LogInfo("No wallet support compiled in!"); }
2525
};
2626

2727
void DummyWalletInit::AddWalletOptions(ArgsManager& argsman) const

src/httpserver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ static bool HTTPBindAddresses(struct evhttp* http)
391391

392392
// Bind addresses
393393
for (std::vector<std::pair<std::string, uint16_t> >::iterator i = endpoints.begin(); i != endpoints.end(); ++i) {
394-
LogPrintf("Binding RPC on address %s port %i\n", i->first, i->second);
394+
LogInfo("Binding RPC on address %s port %i", i->first, i->second);
395395
evhttp_bound_socket *bind_handle = evhttp_bind_socket_with_handle(http, i->first.empty() ? nullptr : i->first.c_str(), i->second);
396396
if (bind_handle) {
397397
const std::optional<CNetAddr> addr{LookupHost(i->first, false)};

src/init.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ bool AppInitParameterInteraction(const ArgsManager& args)
898898
// on the command line or in this chain's section of the config file.
899899
ChainType chain = args.GetChainType();
900900
if (chain == ChainType::SIGNET) {
901-
LogPrintf("Signet derived magic (message start): %s\n", HexStr(chainparams.MessageStart()));
901+
LogInfo("Signet derived magic (message start): %s", HexStr(chainparams.MessageStart()));
902902
}
903903
bilingual_str errors;
904904
for (const auto& arg : args.GetUnsuitableSectionOnlyArgs()) {
@@ -1234,7 +1234,9 @@ static ChainstateLoadResult InitAndLoadChainstate(
12341234
if (!mempool_error.empty()) {
12351235
return {ChainstateLoadStatus::FAILURE_FATAL, mempool_error};
12361236
}
1237-
LogPrintf("* Using %.1f MiB for in-memory UTXO set (plus up to %.1f MiB of unused mempool space)\n", cache_sizes.coins * (1.0 / 1024 / 1024), mempool_opts.max_size_bytes * (1.0 / 1024 / 1024));
1237+
LogInfo("* Using %.1f MiB for in-memory UTXO set (plus up to %.1f MiB of unused mempool space)",
1238+
cache_sizes.coins * (1.0 / 1024 / 1024),
1239+
mempool_opts.max_size_bytes * (1.0 / 1024 / 1024));
12381240
ChainstateManager::Options chainman_opts{
12391241
.chainparams = chainparams,
12401242
.datadir = args.GetDataDirNet(),
@@ -1274,10 +1276,10 @@ static ChainstateLoadResult InitAndLoadChainstate(
12741276
// libbitcoinkernel.
12751277
chainman.snapshot_download_completed = [&node]() {
12761278
if (!node.chainman->m_blockman.IsPruneMode()) {
1277-
LogPrintf("[snapshot] re-enabling NODE_NETWORK services\n");
1279+
LogInfo("[snapshot] re-enabling NODE_NETWORK services");
12781280
node.connman->AddLocalServices(NODE_NETWORK);
12791281
}
1280-
LogPrintf("[snapshot] restarting indexes\n");
1282+
LogInfo("[snapshot] restarting indexes");
12811283
// Drain the validation interface queue to ensure that the old indexes
12821284
// don't have any pending work.
12831285
Assert(node.validation_signals)->SyncWithValidationInterfaceQueue();
@@ -1345,7 +1347,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
13451347
return false;
13461348
}
13471349

1348-
LogPrintf("Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, available_fds);
1350+
LogInfo("Using at most %i automatic connections (%i file descriptors available)", nMaxConnections, available_fds);
13491351

13501352
// Warn about relative -datadir path.
13511353
if (args.IsArgSet("-datadir") && !args.GetPathArg("-datadir").is_absolute()) {
@@ -1402,7 +1404,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
14021404
} catch (const std::exception& e) {
14031405
return InitError(Untranslated(strprintf("Unable to bind to IPC address '%s'. %s", address, e.what())));
14041406
}
1405-
LogPrintf("Listening for IPC requests on address %s\n", address);
1407+
LogInfo("Listening for IPC requests on address %s", address);
14061408
}
14071409
}
14081410

@@ -1495,9 +1497,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
14951497
return false;
14961498
}
14971499
const uint256 asmap_version = (HashWriter{} << asmap).GetHash();
1498-
LogPrintf("Using asmap version %s for IP bucketing\n", asmap_version.ToString());
1500+
LogInfo("Using asmap version %s for IP bucketing", asmap_version.ToString());
14991501
} else {
1500-
LogPrintf("Using /16 prefix for IP bucketing\n");
1502+
LogInfo("Using /16 prefix for IP bucketing");
15011503
}
15021504

15031505
// Initialize netgroup manager
@@ -1753,7 +1755,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
17531755
// As LoadBlockIndex can take several minutes, it's possible the user
17541756
// requested to kill the GUI during the last operation. If so, exit.
17551757
if (ShutdownRequested(node)) {
1756-
LogPrintf("Shutdown requested. Exiting.\n");
1758+
LogInfo("Shutdown requested. Exiting.");
17571759
return false;
17581760
}
17591761

@@ -1808,10 +1810,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
18081810
} else {
18091811
// Prior to setting NODE_NETWORK, check if we can provide historical blocks.
18101812
if (!WITH_LOCK(chainman.GetMutex(), return chainman.BackgroundSyncInProgress())) {
1811-
LogPrintf("Setting NODE_NETWORK on non-prune mode\n");
1813+
LogInfo("Setting NODE_NETWORK on non-prune mode");
18121814
g_local_services = ServiceFlags(g_local_services | NODE_NETWORK);
18131815
} else {
1814-
LogPrintf("Running node in NODE_NETWORK_LIMITED mode until snapshot background sync completes\n");
1816+
LogInfo("Running node in NODE_NETWORK_LIMITED mode until snapshot background sync completes");
18151817
}
18161818
}
18171819

@@ -1870,7 +1872,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
18701872
// Import blocks and ActivateBestChain()
18711873
ImportBlocks(chainman, vImportFiles);
18721874
if (args.GetBoolArg("-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) {
1873-
LogPrintf("Stopping after block import\n");
1875+
LogInfo("Stopping after block import");
18741876
if (!(Assert(node.shutdown_request))()) {
18751877
LogError("Failed to send shutdown signal after finishing block import\n");
18761878
}
@@ -1918,7 +1920,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
19181920
{
19191921
LOCK(chainman.GetMutex());
19201922
const auto& tip{*Assert(chainman.ActiveTip())};
1921-
LogPrintf("block tree size = %u\n", chainman.BlockIndex().size());
1923+
LogInfo("block tree size = %u", chainman.BlockIndex().size());
19221924
chain_active_height = tip.nHeight;
19231925
best_block_time = tip.GetBlockTime();
19241926
if (tip_info) {
@@ -1931,7 +1933,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
19311933
tip_info->header_time = chainman.m_best_header->GetBlockTime();
19321934
}
19331935
}
1934-
LogPrintf("nBestHeight = %d\n", chain_active_height);
1936+
LogInfo("nBestHeight = %d", chain_active_height);
19351937
if (node.peerman) node.peerman->SetBestBlock(chain_active_height, std::chrono::seconds{best_block_time});
19361938

19371939
// Map ports with NAT-PMP
@@ -2061,11 +2063,11 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
20612063
connOptions.m_specified_outgoing = connect;
20622064
}
20632065
if (!connOptions.m_specified_outgoing.empty() && !connOptions.vSeedNodes.empty()) {
2064-
LogPrintf("-seednode is ignored when -connect is used\n");
2066+
LogInfo("-seednode is ignored when -connect is used");
20652067
}
20662068

20672069
if (args.IsArgSet("-dnsseed") && args.GetBoolArg("-dnsseed", DEFAULT_DNSSEED) && args.IsArgSet("-proxy")) {
2068-
LogPrintf("-dnsseed is ignored when -connect is used and -proxy is specified\n");
2070+
LogInfo("-dnsseed is ignored when -connect is used and -proxy is specified");
20692071
}
20702072
}
20712073

src/init/common.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ bool StartLogging(const ArgsManager& args)
115115
}
116116

117117
if (!LogInstance().m_log_timestamps) {
118-
LogPrintf("Startup time: %s\n", FormatISO8601DateTime(GetTime()));
118+
LogInfo("Startup time: %s", FormatISO8601DateTime(GetTime()));
119119
}
120-
LogPrintf("Default data directory %s\n", fs::PathToString(GetDefaultDataDir()));
121-
LogPrintf("Using data directory %s\n", fs::PathToString(gArgs.GetDataDirNet()));
120+
LogInfo("Default data directory %s", fs::PathToString(GetDefaultDataDir()));
121+
LogInfo("Using data directory %s", fs::PathToString(gArgs.GetDataDirNet()));
122122

123123
// Only log conf file usage message if conf file actually exists.
124124
fs::path config_file_path = args.GetConfigFilePath();
@@ -127,12 +127,12 @@ bool StartLogging(const ArgsManager& args)
127127
} else if (fs::is_directory(config_file_path)) {
128128
LogWarning("Config file: %s (is directory, not file)", fs::PathToString(config_file_path));
129129
} else if (fs::exists(config_file_path)) {
130-
LogPrintf("Config file: %s\n", fs::PathToString(config_file_path));
130+
LogInfo("Config file: %s", fs::PathToString(config_file_path));
131131
} else if (args.IsArgSet("-conf")) {
132132
InitWarning(strprintf(_("The specified config file %s does not exist"), fs::PathToString(config_file_path)));
133133
} else {
134134
// Not categorizing as "Warning" because it's the default behavior
135-
LogPrintf("Config file: %s (not found, skipping)\n", fs::PathToString(config_file_path));
135+
LogInfo("Config file: %s (not found, skipping)", fs::PathToString(config_file_path));
136136
}
137137

138138
// Log the config arguments to debug.log
@@ -149,6 +149,6 @@ void LogPackageVersion()
149149
#else
150150
version_string += " (release build)";
151151
#endif
152-
LogPrintf(CLIENT_NAME " version %s\n", version_string);
152+
LogInfo(CLIENT_NAME " version %s", version_string);
153153
}
154154
} // namespace init

src/kernel/chainparams.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ class SigNetParams : public CChainParams {
423423
0,
424424
0,
425425
};
426-
LogPrintf("Signet with challenge %s\n", HexStr(bin));
426+
LogInfo("Signet with challenge %s", HexStr(bin));
427427
}
428428

429429
if (options.seeds) {

src/node/blockstorage.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ void BlockManager::FindFilesToPruneManual(
298298
setFilesToPrune.insert(fileNumber);
299299
count++;
300300
}
301-
LogPrintf("[%s] Prune (Manual): prune_height=%d removed %d blk/rev pairs\n",
301+
LogInfo("[%s] Prune (Manual): prune_height=%d removed %d blk/rev pairs",
302302
chain.GetRole(), last_block_can_prune, count);
303303
}
304304

@@ -418,7 +418,7 @@ bool BlockManager::LoadBlockIndex(const std::optional<uint256>& snapshot_blockha
418418
// to disk, we must bootstrap the value for assumedvalid chainstates
419419
// from the hardcoded assumeutxo chainparams.
420420
base->m_chain_tx_count = au_data.m_chain_tx_count;
421-
LogPrintf("[snapshot] set m_chain_tx_count=%d for %s\n", au_data.m_chain_tx_count, snapshot_blockhash->ToString());
421+
LogInfo("[snapshot] set m_chain_tx_count=%d for %s", au_data.m_chain_tx_count, snapshot_blockhash->ToString());
422422
} else {
423423
// If this isn't called with a snapshot blockhash, make sure the cached snapshot height
424424
// is null. This is relevant during snapshot completion, when the blockman may be loaded
@@ -523,7 +523,7 @@ bool BlockManager::LoadBlockIndexDB(const std::optional<uint256>& snapshot_block
523523
}
524524

525525
// Check presence of blk files
526-
LogPrintf("Checking all blk files are present...\n");
526+
LogInfo("Checking all blk files are present...");
527527
std::set<int> setBlkDataFiles;
528528
for (const auto& [_, block_index] : m_block_index) {
529529
if (block_index.nStatus & BLOCK_HAVE_DATA) {
@@ -622,7 +622,7 @@ void BlockManager::CleanupBlockRevFiles() const
622622
// Glob all blk?????.dat and rev?????.dat files from the blocks directory.
623623
// Remove the rev files immediately and insert the blk file paths into an
624624
// ordered map keyed by block file index.
625-
LogPrintf("Removing unusable blk?????.dat and rev?????.dat files for -reindex with -prune\n");
625+
LogInfo("Removing unusable blk?????.dat and rev?????.dat files for -reindex with -prune");
626626
for (fs::directory_iterator it(m_opts.blocks_dir); it != fs::directory_iterator(); it++) {
627627
const std::string path = fs::PathToString(it->path().filename());
628628
if (fs::is_regular_file(*it) &&
@@ -1233,7 +1233,7 @@ void ImportBlocks(ChainstateManager& chainman, std::span<const fs::path> import_
12331233
if (file.IsNull()) {
12341234
break; // This error is logged in OpenBlockFile
12351235
}
1236-
LogPrintf("Reindexing block file blk%05u.dat...\n", (unsigned int)nFile);
1236+
LogInfo("Reindexing block file blk%05u.dat...", (unsigned int)nFile);
12371237
chainman.LoadExternalBlockFile(file, &pos, &blocks_with_unknown_parent);
12381238
if (chainman.m_interrupt) {
12391239
LogInfo("Interrupt requested. Exit reindexing.");
@@ -1243,7 +1243,7 @@ void ImportBlocks(ChainstateManager& chainman, std::span<const fs::path> import_
12431243
}
12441244
WITH_LOCK(::cs_main, chainman.m_blockman.m_block_tree_db->WriteReindexing(false));
12451245
chainman.m_blockman.m_blockfiles_indexed = true;
1246-
LogPrintf("Reindexing finished\n");
1246+
LogInfo("Reindexing finished");
12471247
// To avoid ending up in a situation without genesis block, re-try initializing (no-op if reindexing worked):
12481248
chainman.ActiveChainstate().LoadGenesisBlock();
12491249
}
@@ -1252,7 +1252,7 @@ void ImportBlocks(ChainstateManager& chainman, std::span<const fs::path> import_
12521252
for (const fs::path& path : import_paths) {
12531253
AutoFile file{fsbridge::fopen(path, "rb")};
12541254
if (!file.IsNull()) {
1255-
LogPrintf("Importing blocks file %s...\n", fs::PathToString(path));
1255+
LogInfo("Importing blocks file %s...", fs::PathToString(path));
12561256
chainman.LoadExternalBlockFile(file);
12571257
if (chainman.m_interrupt) {
12581258
LogInfo("Interrupt requested. Exit block importing.");

src/node/chainstate.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static ChainstateLoadResult CompleteChainstateInitialization(
8484
// block tree into BlockIndex()!
8585

8686
for (Chainstate* chainstate : chainman.GetAll()) {
87-
LogPrintf("Initializing chainstate %s\n", chainstate->ToString());
87+
LogInfo("Initializing chainstate %s", chainstate->ToString());
8888

8989
try {
9090
chainstate->InitCoinsDB(
@@ -145,18 +145,19 @@ ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSize
145145
const ChainstateLoadOptions& options)
146146
{
147147
if (!chainman.AssumedValidBlock().IsNull()) {
148-
LogPrintf("Assuming ancestors of block %s have valid signatures.\n", chainman.AssumedValidBlock().GetHex());
148+
LogInfo("Assuming ancestors of block %s have valid signatures.", chainman.AssumedValidBlock().GetHex());
149149
} else {
150-
LogPrintf("Validating signatures for all blocks.\n");
150+
LogInfo("Validating signatures for all blocks.");
151151
}
152-
LogPrintf("Setting nMinimumChainWork=%s\n", chainman.MinimumChainWork().GetHex());
152+
LogInfo("Setting nMinimumChainWork=%s", chainman.MinimumChainWork().GetHex());
153153
if (chainman.MinimumChainWork() < UintToArith256(chainman.GetConsensus().nMinimumChainWork)) {
154154
LogPrintf("Warning: nMinimumChainWork set below default value of %s\n", chainman.GetConsensus().nMinimumChainWork.GetHex());
155155
}
156156
if (chainman.m_blockman.GetPruneTarget() == BlockManager::PRUNE_TARGET_MANUAL) {
157157
LogInfo("Block pruning enabled. Use RPC call pruneblockchain(height) to manually prune block and undo files.");
158158
} else if (chainman.m_blockman.GetPruneTarget()) {
159-
LogPrintf("Prune configured to target %u MiB on disk for block and undo files.\n", chainman.m_blockman.GetPruneTarget() / 1024 / 1024);
159+
LogInfo("Prune configured to target %u MiB on disk for block and undo files.",
160+
chainman.m_blockman.GetPruneTarget() / 1024 / 1024);
160161
}
161162

162163
LOCK(cs_main);
@@ -171,7 +172,7 @@ ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSize
171172
bool has_snapshot = chainman.DetectSnapshotChainstate();
172173

173174
if (has_snapshot && options.wipe_chainstate_db) {
174-
LogPrintf("[snapshot] deleting snapshot chainstate due to reindexing\n");
175+
LogInfo("[snapshot] deleting snapshot chainstate due to reindexing");
175176
if (!chainman.DeleteSnapshotChainstate()) {
176177
return {ChainstateLoadStatus::FAILURE_FATAL, Untranslated("Couldn't remove snapshot chainstate.")};
177178
}
@@ -195,7 +196,7 @@ ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSize
195196
if (snapshot_completion == SnapshotCompletionResult::SKIPPED) {
196197
// do nothing; expected case
197198
} else if (snapshot_completion == SnapshotCompletionResult::SUCCESS) {
198-
LogPrintf("[snapshot] cleaning up unneeded background chainstate, then reinitializing\n");
199+
LogInfo("[snapshot] cleaning up unneeded background chainstate, then reinitializing");
199200
if (!chainman.ValidatedSnapshotCleanup()) {
200201
return {ChainstateLoadStatus::FAILURE_FATAL, Untranslated("Background chainstate cleanup failed unexpectedly.")};
201202
}

0 commit comments

Comments
 (0)