Skip to content

Conversation

ajtowns
Copy link
Contributor

@ajtowns ajtowns commented Apr 26, 2018

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.

@promag
Copy link
Contributor

promag commented Apr 29, 2018

Concept ACK.

@ajtowns ajtowns force-pushed the earlyconsolelog branch from 20a699a to b65577a Compare May 3, 2018 14:04
@ajtowns
Copy link
Contributor Author

ajtowns commented May 3, 2018

Rebased on top of 12954 and 13148. Nitpicking welcome.

@maflcko
Copy link
Member

maflcko commented May 3, 2018

Is this of any relevance? I had the impression that parameter interaction was done after logging was set up.

@maflcko
Copy link
Member

maflcko commented May 3, 2018

Noting that replacing the LogPrintf with FileWriteStr fixes #13157

@DrahtBot
Copy link
Contributor

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.

@ajtowns
Copy link
Contributor Author

ajtowns commented Aug 7, 2018

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.
@maflcko
Copy link
Member

maflcko commented Sep 9, 2018

The tests seem to fail or deadlock

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 20, 2018

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #15329 (Fix InitError() and InitWarning() content by hebasto)
  • #15266 (memory: Construct globals on first use by MarcoFalke)
  • #14169 (add -debuglogsize= option by SuckShit)
  • #13949 (Introduce MempoolObserver interface to break "policy/fees -> txmempool -> policy/fees" circular dependency by Empact)
  • #10443 (Add fee_est tool for debugging fee estimation code by ryanofsky)

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"
Copy link
Contributor

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? :-)

Copy link
Member

@maflcko maflcko left a 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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
CCriticalSection m_cs_log;
RecursiveMutex m_cs_log;

@DrahtBot
Copy link
Contributor

DrahtBot commented Feb 4, 2019

Needs rebase

@ajtowns
Copy link
Contributor Author

ajtowns commented May 29, 2019

Closing in favour of #16112

@ajtowns ajtowns closed this May 29, 2019
maflcko pushed a commit that referenced this pull request Jun 18, 2019
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
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jun 19, 2019
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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants