-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Log early messages with -printtoconsole #13088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Concept ACK. |
Rebased on top of 12954 and 13148. Nitpicking welcome. |
Is this of any relevance? I had the impression that parameter interaction was done after logging was set up. |
Noting that replacing the |
The last travis run for this pull request was 80 days ago and is thus outdated. To trigger a fresh travis build, this pull request should be closed and re-opened. |
42539bf
to
93483ad
Compare
Rebased, dropped overlapping commit with #13159 (which probably should be merged first), and note that CCriticalSection change introduces dependency loop. |
StartLogging() is used to mark the start of logging generically, whether using -printtoconsole or -debuglogfile.
This ensures log messages prior to StartLogging() are replayed to the console as well as to the debug log file.
Note: this introduces a circular dependency between logging and sync, since sync does logging, and logging does synchronisation.
93483ad
to
383e923
Compare
The tests seem to fail or deadlock |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
@@ -12,6 +12,7 @@ EXPECTED_CIRCULAR_DEPENDENCIES=( | |||
"chainparamsbase -> util -> chainparamsbase" | |||
"checkpoints -> validation -> checkpoints" | |||
"index/txindex -> validation -> index/txindex" | |||
"logging -> sync -> logging" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be required to avoid introducing this circular dependency? :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs rebase to have travis run again
FILE* m_fileout = nullptr; | ||
std::mutex m_file_mutex; | ||
std::list<std::string> m_msgs_before_open; | ||
CCriticalSection m_cs_log; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
CCriticalSection m_cs_log; | |
RecursiveMutex m_cs_log; |
Needs rebase |
Closing in favour of #16112 |
faa2a47 logging: Add threadsafety comments (MarcoFalke) 0b282f9 Log early messages with -printtoconsole (Anthony Towns) 4129874 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 faa2a47 hebasto: ACK faa2a47 kristapsk: ACK faa2a47 (ran added functional test before / after recompiling, didn't do additional testing) Tree-SHA512: 685e2882642fe2a43ce171d42862582dadb840d03cda8236a994322c389ca2a1f3f431b179b2726c155c61793543bb340c568a5455d97f8b83bc7d307a85d387
faa2a47 logging: Add threadsafety comments (MarcoFalke) 0b282f9 Log early messages with -printtoconsole (Anthony Towns) 4129874 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" (bitcoin#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 bitcoin#16098 Fixes bitcoin#13157 Closes bitcoin#13088 ACKs for commit faa2a4: ajtowns: utACK faa2a47 hebasto: ACK faa2a47 kristapsk: ACK faa2a47 (ran added functional test before / after recompiling, didn't do additional testing) Tree-SHA512: 685e2882642fe2a43ce171d42862582dadb840d03cda8236a994322c389ca2a1f3f431b179b2726c155c61793543bb340c568a5455d97f8b83bc7d307a85d387
This allows any log messages sent prior to the
-printtoconsole
option being parsed to be replayed onto the console. This could be handy if option parsing (parameters/config file) wants to output any warnings or info messages.