aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp50
1 files changed, 24 insertions, 26 deletions
diff --git a/src/init.cpp b/src/init.cpp
index f27f148126..7d8f462ef1 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -242,7 +242,7 @@ void Shutdown()
fFeeEstimatesInitialized = false;
}
- // FlushStateToDisk generates a SetBestChain callback, which we should avoid missing
+ // FlushStateToDisk generates a ChainStateFlushed callback, which we should avoid missing
if (pcoinsTip != nullptr) {
FlushStateToDisk();
}
@@ -306,7 +306,7 @@ static void HandleSIGTERM(int)
static void HandleSIGHUP(int)
{
- fReopenDebugLog = true;
+ g_logger->m_reopen_file = true;
}
#else
static BOOL WINAPI consoleCtrlHandler(DWORD dwCtrlType)
@@ -328,12 +328,12 @@ static void registerSignalHandler(int signal, void(*handler)(int))
}
#endif
-void OnRPCStarted()
+static void OnRPCStarted()
{
uiInterface.NotifyBlockTip.connect(&RPCNotifyBlockChange);
}
-void OnRPCStopped()
+static void OnRPCStopped()
{
uiInterface.NotifyBlockTip.disconnect(&RPCNotifyBlockChange);
RPCNotifyBlockChange(false, nullptr);
@@ -604,7 +604,7 @@ struct CImportingNow
// rev files since they'll be rewritten by the reindex anyway. This ensures that vinfoBlockFile
// is in sync with what's actually on disk by the time we start downloading, so that pruning
// works correctly.
-void CleanupBlockRevFiles()
+static void CleanupBlockRevFiles()
{
std::map<std::string, fs::path> mapBlockFiles;
@@ -639,7 +639,7 @@ void CleanupBlockRevFiles()
}
}
-void ThreadImport(std::vector<fs::path> vImportFiles)
+static void ThreadImport(std::vector<fs::path> vImportFiles)
{
const CChainParams& chainparams = Params();
RenameThread("bitcoin-loadblk");
@@ -718,7 +718,7 @@ void ThreadImport(std::vector<fs::path> vImportFiles)
* Ensure that Bitcoin is running in a usable environment with all
* necessary library support.
*/
-bool InitSanityCheck(void)
+static bool InitSanityCheck(void)
{
if(!ECC_InitSanityCheck()) {
InitError("Elliptic curve cryptography sanity check failure. Aborting.");
@@ -736,7 +736,7 @@ bool InitSanityCheck(void)
return true;
}
-bool AppInitServers()
+static bool AppInitServers()
{
RPCServer::OnStarted(&OnRPCStarted);
RPCServer::OnStopped(&OnRPCStopped);
@@ -835,15 +835,18 @@ static std::string ResolveErrMsg(const char * const optname, const std::string&
*/
void InitLogging()
{
+ g_logger->m_print_to_file = !gArgs.IsArgNegated("-debuglogfile");
+ g_logger->m_file_path = AbsPathForConfigVal(gArgs.GetArg("-debuglogfile", DEFAULT_DEBUGLOGFILE));
+
// Add newlines to the logfile to distinguish this execution from the last
// one; called before console logging is set up, so this is only sent to
// debug.log.
LogPrintf("\n\n\n\n\n");
- fPrintToConsole = gArgs.GetBoolArg("-printtoconsole", !gArgs.GetBoolArg("-daemon", false));
- fPrintToDebugLog = !gArgs.IsArgNegated("-debuglogfile");
- fLogTimestamps = gArgs.GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS);
- fLogTimeMicros = gArgs.GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS);
+ g_logger->m_print_to_console = gArgs.GetBoolArg("-printtoconsole", !gArgs.GetBoolArg("-daemon", false));
+ g_logger->m_log_timestamps = gArgs.GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS);
+ g_logger->m_log_time_micros = gArgs.GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS);
+
fLogIPs = gArgs.GetBoolArg("-logips", DEFAULT_LOGIPS);
std::string version_string = FormatFullVersion();
@@ -973,24 +976,18 @@ bool AppInitParameterInteraction()
if (std::none_of(categories.begin(), categories.end(),
[](std::string cat){return cat == "0" || cat == "none";})) {
for (const auto& cat : categories) {
- uint32_t flag = 0;
- if (!GetLogCategory(&flag, &cat)) {
+ if (!g_logger->EnableCategory(cat)) {
InitWarning(strprintf(_("Unsupported logging category %s=%s."), "-debug", cat));
- continue;
}
- logCategories |= flag;
}
}
}
// Now remove the logging categories which were explicitly excluded
for (const std::string& cat : gArgs.GetArgs("-debugexclude")) {
- uint32_t flag = 0;
- if (!GetLogCategory(&flag, &cat)) {
+ if (!g_logger->DisableCategory(cat)) {
InitWarning(strprintf(_("Unsupported logging category %s=%s."), "-debugexclude", cat));
- continue;
}
- logCategories &= ~flag;
}
// Check for -debugnet
@@ -1241,18 +1238,19 @@ bool AppInitMain()
#ifndef WIN32
CreatePidFile(GetPidFile(), getpid());
#endif
- if (fPrintToDebugLog) {
- if (gArgs.GetBoolArg("-shrinkdebugfile", logCategories == BCLog::NONE)) {
+ if (g_logger->m_print_to_file) {
+ if (gArgs.GetBoolArg("-shrinkdebugfile", g_logger->DefaultShrinkDebugFile())) {
// Do this first since it both loads a bunch of debug.log into memory,
// and because this needs to happen before any other debug.log printing
- ShrinkDebugFile();
+ g_logger->ShrinkDebugFile();
}
- if (!OpenDebugLog()) {
- return InitError(strprintf("Could not open debug log file %s", GetDebugLogPath().string()));
+ if (!g_logger->OpenDebugLog()) {
+ return InitError(strprintf("Could not open debug log file %s",
+ g_logger->m_file_path.string()));
}
}
- if (!fLogTimestamps)
+ if (!g_logger->m_log_timestamps)
LogPrintf("Startup time: %s\n", FormatISO8601DateTime(GetTime()));
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string());
LogPrintf("Using data directory %s\n", GetDataDir().string());