Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 1,393 Lines • ▼ Show 20 Lines | |||||
* Note that this is called very early in the process lifetime, so you should be | * Note that this is called very early in the process lifetime, so you should be | ||||
* careful about what global state you rely on here. | * careful about what global state you rely on here. | ||||
*/ | */ | ||||
void InitLogging() { | void InitLogging() { | ||||
LogInstance().m_print_to_file = !gArgs.IsArgNegated("-debuglogfile"); | LogInstance().m_print_to_file = !gArgs.IsArgNegated("-debuglogfile"); | ||||
LogInstance().m_file_path = AbsPathForConfigVal( | LogInstance().m_file_path = AbsPathForConfigVal( | ||||
gArgs.GetArg("-debuglogfile", DEFAULT_DEBUGLOGFILE)); | 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"); | |||||
LogInstance().m_print_to_console = gArgs.GetBoolArg( | LogInstance().m_print_to_console = gArgs.GetBoolArg( | ||||
"-printtoconsole", !gArgs.GetBoolArg("-daemon", false)); | "-printtoconsole", !gArgs.GetBoolArg("-daemon", false)); | ||||
LogInstance().m_log_timestamps = | LogInstance().m_log_timestamps = | ||||
gArgs.GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS); | gArgs.GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS); | ||||
LogInstance().m_log_time_micros = | LogInstance().m_log_time_micros = | ||||
gArgs.GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS); | gArgs.GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS); | ||||
LogInstance().m_log_threadnames = | LogInstance().m_log_threadnames = | ||||
gArgs.GetBoolArg("-logthreadnames", DEFAULT_LOGTHREADNAMES); | gArgs.GetBoolArg("-logthreadnames", DEFAULT_LOGTHREADNAMES); | ||||
▲ Show 20 Lines • Show All 463 Lines • ▼ Show 20 Lines | #endif | ||||
if (logger.m_print_to_file) { | if (logger.m_print_to_file) { | ||||
if (gArgs.GetBoolArg("-shrinkdebugfile", | if (gArgs.GetBoolArg("-shrinkdebugfile", | ||||
logger.DefaultShrinkDebugFile())) { | logger.DefaultShrinkDebugFile())) { | ||||
// Do this first since it both loads a bunch of debug.log into | // Do this first since it both loads a bunch of debug.log into | ||||
// memory, and because this needs to happen before any other | // memory, and because this needs to happen before any other | ||||
// debug.log printing. | // debug.log printing. | ||||
logger.ShrinkDebugFile(); | logger.ShrinkDebugFile(); | ||||
} | } | ||||
} | |||||
if (!logger.OpenDebugLog()) { | if (!logger.StartLogging()) { | ||||
return InitError(strprintf("Could not open debug log file %s", | return InitError(strprintf("Could not open debug log file %s", | ||||
logger.m_file_path.string())); | logger.m_file_path.string())); | ||||
} | } | ||||
} | |||||
if (!logger.m_log_timestamps) { | if (!logger.m_log_timestamps) { | ||||
LogPrintf("Startup time: %s\n", FormatISO8601DateTime(GetTime())); | LogPrintf("Startup time: %s\n", FormatISO8601DateTime(GetTime())); | ||||
} | } | ||||
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string()); | LogPrintf("Default data directory %s\n", GetDefaultDataDir().string()); | ||||
LogPrintf("Using data directory %s\n", GetDataDir().string()); | LogPrintf("Using data directory %s\n", GetDataDir().string()); | ||||
LogPrintf( | LogPrintf( | ||||
"Using config file %s\n", | "Using config file %s\n", | ||||
▲ Show 20 Lines • Show All 648 Lines • Show Last 20 Lines |