diff --git a/src/init.cpp b/src/init.cpp index b825c8ce21798..9892e37dee4fc 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -187,7 +187,7 @@ static void RemovePidFile(const ArgsManager& args) const auto pid_path{GetPidFile(args)}; if (std::error_code error; !fs::remove(pid_path, error)) { std::string msg{error ? error.message() : "File does not exist"}; - LogPrintf("Unable to remove PID file (%s): %s\n", fs::PathToString(pid_path), msg); + LogInfo("Unable to remove PID file (%s): %s\n", fs::PathToString(pid_path), msg); } } @@ -270,7 +270,7 @@ void Shutdown(NodeContext& node) static Mutex g_shutdown_mutex; TRY_LOCK(g_shutdown_mutex, lock_shutdown); if (!lock_shutdown) return; - LogPrintf("%s: In progress...\n", __func__); + LogInfo("%s: In progress...\n", __func__); Assert(node.args); /// Note: Shutdown() must be able to handle cases in which initialization failed part of the way, @@ -383,7 +383,7 @@ void Shutdown(NodeContext& node) RemovePidFile(*node.args); - LogPrintf("%s: done\n", __func__); + LogInfo("%s: done\n", __func__); } /** @@ -407,7 +407,7 @@ static void HandleSIGHUP(int) static BOOL WINAPI consoleCtrlHandler(DWORD dwCtrlType) { if (!(*Assert(g_shutdown))()) { - LogPrintf("Error: failed to send shutdown signal on Ctrl-C\n"); + LogInfo("Error: failed to send shutdown signal on Ctrl-C\n"); return false; } Sleep(INFINITE); @@ -437,7 +437,7 @@ static void OnRPCStopped() rpc_notify_block_change_connection.disconnect(); RPCNotifyBlockChange(nullptr); g_best_block_cv.notify_all(); - LogPrint(BCLog::RPC, "RPC stopped.\n"); + LogDebug(BCLog::RPC, "RPC stopped.\n"); } void SetupServerArgs(ArgsManager& argsman) @@ -725,73 +725,73 @@ void InitParameterInteraction(ArgsManager& args) // even when -connect or -proxy is specified if (args.IsArgSet("-bind")) { if (args.SoftSetBoolArg("-listen", true)) - LogPrintf("%s: parameter interaction: -bind set -> setting -listen=1\n", __func__); + LogInfo("%s: parameter interaction: -bind set -> setting -listen=1\n", __func__); } if (args.IsArgSet("-whitebind")) { if (args.SoftSetBoolArg("-listen", true)) - LogPrintf("%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__); + LogInfo("%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__); } if (args.IsArgSet("-connect") || args.GetIntArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS) <= 0) { // when only connecting to trusted nodes, do not seed via DNS, or listen by default if (args.SoftSetBoolArg("-dnsseed", false)) - LogPrintf("%s: parameter interaction: -connect or -maxconnections=0 set -> setting -dnsseed=0\n", __func__); + LogInfo("%s: parameter interaction: -connect or -maxconnections=0 set -> setting -dnsseed=0\n", __func__); if (args.SoftSetBoolArg("-listen", false)) - LogPrintf("%s: parameter interaction: -connect or -maxconnections=0 set -> setting -listen=0\n", __func__); + LogInfo("%s: parameter interaction: -connect or -maxconnections=0 set -> setting -listen=0\n", __func__); } std::string proxy_arg = args.GetArg("-proxy", ""); if (proxy_arg != "" && proxy_arg != "0") { // to protect privacy, do not listen by default if a default proxy server is specified if (args.SoftSetBoolArg("-listen", false)) - LogPrintf("%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__); + LogInfo("%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__); // to protect privacy, do not map ports when a proxy is set. The user may still specify -listen=1 // to listen locally, so don't rely on this happening through -listen below. if (args.SoftSetBoolArg("-upnp", false)) - LogPrintf("%s: parameter interaction: -proxy set -> setting -upnp=0\n", __func__); + LogInfo("%s: parameter interaction: -proxy set -> setting -upnp=0\n", __func__); if (args.SoftSetBoolArg("-natpmp", false)) { - LogPrintf("%s: parameter interaction: -proxy set -> setting -natpmp=0\n", __func__); + LogInfo("%s: parameter interaction: -proxy set -> setting -natpmp=0\n", __func__); } // to protect privacy, do not discover addresses by default if (args.SoftSetBoolArg("-discover", false)) - LogPrintf("%s: parameter interaction: -proxy set -> setting -discover=0\n", __func__); + LogInfo("%s: parameter interaction: -proxy set -> setting -discover=0\n", __func__); } if (!args.GetBoolArg("-listen", DEFAULT_LISTEN)) { // do not map ports or try to retrieve public IP when not listening (pointless) if (args.SoftSetBoolArg("-upnp", false)) - LogPrintf("%s: parameter interaction: -listen=0 -> setting -upnp=0\n", __func__); + LogInfo("%s: parameter interaction: -listen=0 -> setting -upnp=0\n", __func__); if (args.SoftSetBoolArg("-natpmp", false)) { - LogPrintf("%s: parameter interaction: -listen=0 -> setting -natpmp=0\n", __func__); + LogInfo("%s: parameter interaction: -listen=0 -> setting -natpmp=0\n", __func__); } if (args.SoftSetBoolArg("-discover", false)) - LogPrintf("%s: parameter interaction: -listen=0 -> setting -discover=0\n", __func__); + LogInfo("%s: parameter interaction: -listen=0 -> setting -discover=0\n", __func__); if (args.SoftSetBoolArg("-listenonion", false)) - LogPrintf("%s: parameter interaction: -listen=0 -> setting -listenonion=0\n", __func__); + LogInfo("%s: parameter interaction: -listen=0 -> setting -listenonion=0\n", __func__); if (args.SoftSetBoolArg("-i2pacceptincoming", false)) { - LogPrintf("%s: parameter interaction: -listen=0 -> setting -i2pacceptincoming=0\n", __func__); + LogInfo("%s: parameter interaction: -listen=0 -> setting -i2pacceptincoming=0\n", __func__); } } if (args.IsArgSet("-externalip")) { // if an explicit public IP is specified, do not try to find others if (args.SoftSetBoolArg("-discover", false)) - LogPrintf("%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__); + LogInfo("%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__); } if (args.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY)) { // disable whitelistrelay in blocksonly mode if (args.SoftSetBoolArg("-whitelistrelay", false)) - LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -whitelistrelay=0\n", __func__); + LogInfo("%s: parameter interaction: -blocksonly=1 -> setting -whitelistrelay=0\n", __func__); // Reduce default mempool size in blocksonly mode to avoid unexpected resource usage if (args.SoftSetArg("-maxmempool", ToString(DEFAULT_BLOCKSONLY_MAX_MEMPOOL_SIZE_MB))) - LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -maxmempool=%d\n", __func__, DEFAULT_BLOCKSONLY_MAX_MEMPOOL_SIZE_MB); + LogInfo("%s: parameter interaction: -blocksonly=1 -> setting -maxmempool=%d\n", __func__, DEFAULT_BLOCKSONLY_MAX_MEMPOOL_SIZE_MB); } // Forcing relay from whitelisted hosts implies we will accept relays from them in the first place. if (args.GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY)) { if (args.SoftSetBoolArg("-whitelistrelay", true)) - LogPrintf("%s: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1\n", __func__); + LogInfo("%s: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1\n", __func__); } if (args.IsArgSet("-onlynet")) { const auto onlynets = args.GetArgs("-onlynet"); @@ -800,7 +800,7 @@ void InitParameterInteraction(ArgsManager& args) return n == NET_IPV4 || n == NET_IPV6; }); if (!clearnet_reachable && args.SoftSetBoolArg("-dnsseed", false)) { - LogPrintf("%s: parameter interaction: -onlynet excludes IPv4 and IPv6 -> setting -dnsseed=0\n", __func__); + LogInfo("%s: parameter interaction: -onlynet excludes IPv4 and IPv6 -> setting -dnsseed=0\n", __func__); } } } @@ -835,7 +835,7 @@ std::set g_enabled_filter_types; // Since LogPrintf may itself allocate memory, set the handler directly // to terminate first. std::set_new_handler(std::terminate); - LogPrintf("Error: Out of memory. Terminating.\n"); + LogInfo("Error: Out of memory. Terminating.\n"); // The log was successful, terminate now. std::terminate(); @@ -890,7 +890,7 @@ bool AppInitParameterInteraction(const ArgsManager& args) // on the command line or in this chain's section of the config file. ChainType chain = args.GetChainType(); if (chain == ChainType::SIGNET) { - LogPrintf("Signet derived magic (message start): %s\n", HexStr(chainparams.MessageStart())); + LogInfo("Signet derived magic (message start): %s\n", HexStr(chainparams.MessageStart())); } bilingual_str errors; for (const auto& arg : args.GetUnsuitableSectionOnlyArgs()) { @@ -1117,11 +1117,11 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) return false; } - LogPrintf("Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD); + LogInfo("Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD); // Warn about relative -datadir path. if (args.IsArgSet("-datadir") && !args.GetPathArg("-datadir").is_absolute()) { - LogPrintf("Warning: relative datadir option '%s' specified, which will be interpreted relative to the " + LogInfo("Warning: relative datadir option '%s' specified, which will be interpreted relative to the " "current working directory '%s'. This is fragile, because if bitcoin is started in the future " "from a different location, it will be unable to locate the current data files. There could " "also be data loss if bitcoin is started while in a temporary directory.\n", @@ -1151,9 +1151,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) node.scheduler->scheduleEvery([&args, &node]{ constexpr uint64_t min_disk_space = 50 << 20; // 50 MB if (!CheckDiskSpace(args.GetBlocksDirPath(), min_disk_space)) { - LogPrintf("Shutting down due to lack of disk space!\n"); + LogInfo("Shutting down due to lack of disk space!\n"); if (!(*Assert(node.shutdown))()) { - LogPrintf("Error: failed to send shutdown signal after disk space check\n"); + LogInfo("Error: failed to send shutdown signal after disk space check\n"); } } }, std::chrono::minutes{5}); @@ -1227,9 +1227,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) return false; } const uint256 asmap_version = (HashWriter{} << asmap).GetHash(); - LogPrintf("Using asmap version %s for IP bucketing\n", asmap_version.ToString()); + LogInfo("Using asmap version %s for IP bucketing\n", asmap_version.ToString()); } else { - LogPrintf("Using /16 prefix for IP bucketing\n"); + LogInfo("Using /16 prefix for IP bucketing\n"); } // Initialize netgroup manager @@ -1463,16 +1463,16 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) // cache size calculations CacheSizes cache_sizes = CalculateCacheSizes(args, g_enabled_filter_types.size()); - LogPrintf("Cache configuration:\n"); - LogPrintf("* Using %.1f MiB for block index database\n", cache_sizes.block_tree_db * (1.0 / 1024 / 1024)); + LogInfo("Cache configuration:\n"); + LogInfo("* Using %.1f MiB for block index database\n", cache_sizes.block_tree_db * (1.0 / 1024 / 1024)); if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX)) { - LogPrintf("* Using %.1f MiB for transaction index database\n", cache_sizes.tx_index * (1.0 / 1024 / 1024)); + LogInfo("* Using %.1f MiB for transaction index database\n", cache_sizes.tx_index * (1.0 / 1024 / 1024)); } for (BlockFilterType filter_type : g_enabled_filter_types) { - LogPrintf("* Using %.1f MiB for %s block filter index database\n", + LogInfo("* Using %.1f MiB for %s block filter index database\n", cache_sizes.filter_index * (1.0 / 1024 / 1024), BlockFilterTypeName(filter_type)); } - LogPrintf("* Using %.1f MiB for chain state database\n", cache_sizes.coins_db * (1.0 / 1024 / 1024)); + LogInfo("* Using %.1f MiB for chain state database\n", cache_sizes.coins_db * (1.0 / 1024 / 1024)); assert(!node.mempool); assert(!node.chainman); @@ -1490,7 +1490,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) if (mempool_opts.max_size_bytes < 0 || mempool_opts.max_size_bytes < descendant_limit_bytes) { return InitError(strprintf(_("-maxmempool must be at least %d MB"), std::ceil(descendant_limit_bytes / 1'000'000.0))); } - 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)); + LogInfo("* 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)); for (bool fLoaded = false; !fLoaded && !ShutdownRequested(node);) { node.mempool = std::make_unique(mempool_opts); @@ -1502,7 +1502,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) // dependency between validation and index/base, since the latter is not in // libbitcoinkernel. chainman.restart_indexes = [&node]() { - LogPrintf("[snapshot] restarting indexes\n"); + LogInfo("[snapshot] restarting indexes\n"); // Drain the validation interface queue to ensure that the old indexes // don't have any pending work. @@ -1512,7 +1512,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) index->Interrupt(); index->Stop(); if (!(index->Init() && index->StartBackgroundSync())) { - LogPrintf("[snapshot] WARNING failed to restart index %s on snapshot chain\n", index->GetName()); + LogInfo("[snapshot] WARNING failed to restart index %s on snapshot chain\n", index->GetName()); } } }; @@ -1537,7 +1537,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) try { return f(); } catch (const std::exception& e) { - LogPrintf("%s\n", e.what()); + LogInfo("%s\n", e.what()); return std::make_tuple(node::ChainstateLoadStatus::FAILURE, _("Error opening block database")); } }; @@ -1551,7 +1551,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) std::tie(status, error) = catch_exceptions([&]{ return VerifyLoadedChainstate(chainman, options);}); if (status == node::ChainstateLoadStatus::SUCCESS) { fLoaded = true; - LogPrintf(" block index %15dms\n", Ticks(SteadyClock::now() - load_block_index_start_time)); + LogInfo(" block index %15dms\n", Ticks(SteadyClock::now() - load_block_index_start_time)); } } @@ -1569,10 +1569,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) if (fRet) { fReindex = true; if (!Assert(node.shutdown)->reset()) { - LogPrintf("Internal error: failed to reset shutdown signal.\n"); + LogInfo("Internal error: failed to reset shutdown signal.\n"); } } else { - LogPrintf("Aborted block database rebuild. Exiting.\n"); + LogInfo("Aborted block database rebuild. Exiting.\n"); return false; } } else { @@ -1585,7 +1585,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) // requested to kill the GUI during the last operation. If so, exit. // As the program has not fully started yet, Shutdown() is possibly overkill. if (ShutdownRequested(node)) { - LogPrintf("Shutdown requested. Exiting.\n"); + LogInfo("Shutdown requested. Exiting.\n"); return false; } @@ -1637,7 +1637,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) } } } else { - LogPrintf("Setting NODE_NETWORK on non-prune mode\n"); + LogInfo("Setting NODE_NETWORK on non-prune mode\n"); nLocalServices = ServiceFlags(nLocalServices | NODE_NETWORK); } @@ -1704,9 +1704,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) // Import blocks ImportBlocks(chainman, vImportFiles); if (args.GetBoolArg("-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) { - LogPrintf("Stopping after block import\n"); + LogInfo("Stopping after block import\n"); if (!(*Assert(node.shutdown))()) { - LogPrintf("Error: failed to send shutdown signal after finishing block import\n"); + LogInfo("Error: failed to send shutdown signal after finishing block import\n"); } return; } @@ -1745,7 +1745,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) //// debug print { LOCK(cs_main); - LogPrintf("block tree size = %u\n", chainman.BlockIndex().size()); + LogInfo("block tree size = %u\n", chainman.BlockIndex().size()); chain_active_height = chainman.ActiveChain().Height(); if (tip_info) { tip_info->block_height = chain_active_height; @@ -1757,7 +1757,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) tip_info->header_time = chainman.m_best_header->GetBlockTime(); } } - LogPrintf("nBestHeight = %d\n", chain_active_height); + LogInfo("nBestHeight = %d\n", chain_active_height); if (node.peerman) node.peerman->SetBestHeight(chain_active_height); // Map ports with UPnP or NAT-PMP. @@ -1873,11 +1873,11 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) connOptions.m_specified_outgoing = connect; } if (!connOptions.m_specified_outgoing.empty() && !connOptions.vSeedNodes.empty()) { - LogPrintf("-seednode is ignored when -connect is used\n"); + LogInfo("-seednode is ignored when -connect is used\n"); } if (args.IsArgSet("-dnsseed") && args.GetBoolArg("-dnsseed", DEFAULT_DNSSEED) && args.IsArgSet("-proxy")) { - LogPrintf("-dnsseed is ignored when -connect is used and -proxy is specified\n"); + LogInfo("-dnsseed is ignored when -connect is used and -proxy is specified\n"); } }