Skip to content

Conversation

laanwj
Copy link
Member

@laanwj laanwj commented May 3, 2018

The log messages before command line arguments have been parsed will not have microseconds. Make parsing robust to lack of microseconds so that sorting is done correctly, and make their timestamps show as '.000000' to line up the log.

Before (note the weird sorting and ordering):

 node0 
2018-05-02T12:16:13Z 
 node1 
2018-05-02T12:16:13Z 
 node2 
2018-05-02T12:16:13Z 
 test  2018-05-02T12:16:13.310000Z TestFramework (INFO): Initializing test directory /tmp/testdssm30sn 

After:

 node0 2018-05-02T12:16:13.000000Z  
 node1 2018-05-02T12:16:13.000000Z  
 node2 2018-05-02T12:16:13.000000Z  
 test  2018-05-02T12:16:13.310000Z TestFramework (INFO): Initializing test directory /tmp/testdssm30sn 
 test  2018-05-02T12:16:13.314000Z TestFramework.node0 (DEBUG): bitcoind started, waiting for RPC to come up 
 test  2018-05-02T12:16:13.316000Z TestFramework.node1 (DEBUG): bitcoind started, waiting for RPC to come up 
 test  2018-05-02T12:16:13.319000Z TestFramework.node2 (DEBUG): bitcoind started, waiting for RPC to come up 

The log messages before command line arguments have been parsed will
not have microseconds. Make parsing robust to lack of microseconds so
that sorting is done correctly, and make their timestamps show as
'.000000' to line up the log.
@laanwj laanwj added the Tests label May 3, 2018
yield LogEvent(timestamp=timestamp, source=source, event=event.rstrip())
event = line
timestamp = time_match.group()
if event or timestamp:
Copy link
Member Author

Choose a reason for hiding this comment

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

Could keep this as if event to not show the (initial) empty log message. That's a matter of taste, I guess.

@maflcko
Copy link
Member

maflcko commented May 3, 2018

Noting that this is fixed by #13088

@laanwj
Copy link
Member Author

laanwj commented May 3, 2018

Ok...

@laanwj laanwj closed this May 3, 2018
@maflcko
Copy link
Member

maflcko commented May 28, 2019

This is fixed in

as a side effect of changing the LogPrintf("\n\n\n\n\n"); into a FileWriteStr("\n\n\n\n\n", m_fileout);

@maflcko maflcko reopened this May 28, 2019
@maflcko maflcko closed this May 28, 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.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants