mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
Merge #13004: Print to console by default when not run with -daemon
6a3b0d3Print to console by default when not run with -daemon (Evan Klitzke) Pull request description: Cherry-pickedef6fa1c38efrom the "up for grabs" PR: "Smarter default behavior for -printtoconsole" (#12689). See previous review in #12689. Tree-SHA512: 8923a89b9c8973286d53e960d3c464b1cd026cd5a5911ba62f9f972c83684417dc4004101815dfe987fc1e1baaec1fdd90748a0866bb5548e974d77b3135d43b
This commit is contained in:
26
src/init.cpp
26
src/init.cpp
@@ -814,14 +814,25 @@ static std::string ResolveErrMsg(const char * const optname, const std::string&
|
||||
return strprintf(_("Cannot resolve -%s address: '%s'"), optname, strBind);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize global loggers.
|
||||
*
|
||||
* Note that this is called very early in the process lifetime, so you should be
|
||||
* careful about what global state you rely on here.
|
||||
*/
|
||||
void InitLogging()
|
||||
{
|
||||
fPrintToConsole = gArgs.GetBoolArg("-printtoconsole", false);
|
||||
// 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);
|
||||
fLogIPs = gArgs.GetBoolArg("-logips", DEFAULT_LOGIPS);
|
||||
|
||||
LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
|
||||
std::string version_string = FormatFullVersion();
|
||||
#ifdef DEBUG
|
||||
version_string += " (debug build)";
|
||||
@@ -1215,13 +1226,12 @@ bool AppInitMain()
|
||||
#ifndef WIN32
|
||||
CreatePidFile(GetPidFile(), getpid());
|
||||
#endif
|
||||
if (gArgs.GetBoolArg("-shrinkdebugfile", logCategories == BCLog::NONE)) {
|
||||
// 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();
|
||||
}
|
||||
|
||||
if (fPrintToDebugLog) {
|
||||
if (gArgs.GetBoolArg("-shrinkdebugfile", logCategories == BCLog::NONE)) {
|
||||
// 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();
|
||||
}
|
||||
if (!OpenDebugLog()) {
|
||||
return InitError(strprintf("Could not open debug log file %s", GetDebugLogPath().string()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user