diff options
author | MarcoFalke <falke.marco@gmail.com> | 2019-06-18 12:32:18 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2019-06-18 12:32:32 -0400 |
commit | 0853d8d2fd3cd19c3aea495f228222c7a8536e08 (patch) | |
tree | 6c4c16c5a34c4ea26f987527b864a8431202e8dd /src/init.cpp | |
parent | 6c9d3c704f38600c68f897b1dff3ce19c1620be4 (diff) | |
parent | faa2a47cd7bcdbd187035c76f8dbd0442f6818dc (diff) |
Merge #16112: util: Log early messages
faa2a47cd7 logging: Add threadsafety comments (MarcoFalke)
0b282f9b00 Log early messages with -printtoconsole (Anthony Towns)
412987430c Replace 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:
utACK faa2a47cd7bcdbd187035c76f8dbd0442f6818dc
hebasto:
ACK faa2a47cd7bcdbd187035c76f8dbd0442f6818dc
kristapsk:
ACK faa2a47cd7bcdbd187035c76f8dbd0442f6818dc (ran added functional test before / after recompiling, didn't do additional testing)
Tree-SHA512: 685e2882642fe2a43ce171d42862582dadb840d03cda8236a994322c389ca2a1f3f431b179b2726c155c61793543bb340c568a5455d97f8b83bc7d307a85d387
Diffstat (limited to 'src/init.cpp')
-rw-r--r-- | src/init.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/init.cpp b/src/init.cpp index 2a10f28a84..6625080c6e 100644 --- a/src/init.cpp +++ b/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) |