mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
Merge #16112: util: Log early messages
faa2a47cd7logging: Add threadsafety comments (MarcoFalke)0b282f9b00Log early messages with -printtoconsole (Anthony Towns)412987430cReplace OpenDebugLog() with StartLogging() (Anthony Towns) Pull request description: Early log messages are dropped on the floor and they'd never make it to the console or debug log. This can be tested by running the test included in this pull request without re-compiling the `bitcoind`. Fix that by buffering early messages and flushing them as soon as all logging options have been initialized and logging has been started. This pull request is identical to "Log early messages with -printtoconsole" (#13088) by **ajtowns**, with the following changes: * Rebased * Added docstrings for `m_buffering` and `StartLogging` * Switch `CCriticalSection` (aka `RecursiveMutex`) to just `Mutex` in the last commit * Added tests Fixes #16098 Fixes #13157 Closes #13088 ACKs for commit faa2a4: ajtowns: utACKfaa2a47cd7hebasto: ACKfaa2a47cd7kristapsk: ACKfaa2a47cd7(ran added functional test before / after recompiling, didn't do additional testing) Tree-SHA512: 685e2882642fe2a43ce171d42862582dadb840d03cda8236a994322c389ca2a1f3f431b179b2726c155c61793543bb340c568a5455d97f8b83bc7d307a85d387
This commit is contained in:
10
src/init.cpp
10
src/init.cpp
@@ -852,12 +852,6 @@ void InitLogging()
|
||||
{
|
||||
LogInstance().m_print_to_file = !gArgs.IsArgNegated("-debuglogfile");
|
||||
LogInstance().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");
|
||||
|
||||
LogInstance().m_print_to_console = gArgs.GetBoolArg("-printtoconsole", !gArgs.GetBoolArg("-daemon", false));
|
||||
LogInstance().m_log_timestamps = gArgs.GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS);
|
||||
LogInstance().m_log_time_micros = gArgs.GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS);
|
||||
@@ -1237,10 +1231,10 @@ bool AppInitMain(InitInterfaces& interfaces)
|
||||
// and because this needs to happen before any other debug.log printing
|
||||
LogInstance().ShrinkDebugFile();
|
||||
}
|
||||
if (!LogInstance().OpenDebugLog()) {
|
||||
}
|
||||
if (!LogInstance().StartLogging()) {
|
||||
return InitError(strprintf("Could not open debug log file %s",
|
||||
LogInstance().m_file_path.string()));
|
||||
}
|
||||
}
|
||||
|
||||
if (!LogInstance().m_log_timestamps)
|
||||
|
||||
Reference in New Issue
Block a user