Skip to content

Conversation

@jnewbery
Copy link
Contributor

Currently, if mocktime is set, the logs will be timestamped with the mocktime instead of the system time. It's often useful to have the system time in the logs (for example, when running an integration test, it's useful to know what bitcoind was doing at system time so you can see how it's interacting with the test framework or other bitcoind nodes).

This PR timestamps the log with the actual system time, and also prints out the mocktime if mocktime is being used.

@sdaftuar

@laanwj
Copy link
Member

laanwj commented May 11, 2017

An alternative suggestion would be to log changes to the mock time, instead of prepending it to every line, which causes vary long lines.

@sdaftuar
Copy link
Member

This looks reasonable to me, utACK. This will fix the issues that test/functional/combine_logs has with tests using mocktime, right?

@laanwj I'd personally prefer to have the extra timestamp on each line when using mocktime -- one use case I have is for my simulation environment, where mocktime is set on every message (tx, block, etc) that is delivered to bitcoind. Adding an extra line for each change in mocktime would add substantial clutter, and also make reading/parsing the actual debug output more difficult (the mocktime is usually more interesting to me than the system time).

@laanwj
Copy link
Member

laanwj commented May 11, 2017

OK as this is only used for testing (and only a subset of the tests, as that) I'm fine with adding it to every line.

Copy link
Contributor

@kallewoof kallewoof left a comment

Choose a reason for hiding this comment

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

utACK 761392d

@laanwj laanwj merged commit 761392d into bitcoin:master May 16, 2017
laanwj added a commit that referenced this pull request May 16, 2017
761392d [logging] log system time and mock time (John Newbery)

Tree-SHA512: 0a4b3ad74bcac201be490fe12e4b45adeabc39030ac46f40e1aeb2a20b2f3963e4468e65798d8aaeca1818759cab55ff2b2aa214500aa11571492c3301dd31c1
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 24, 2019
761392d [logging] log system time and mock time (John Newbery)

Tree-SHA512: 0a4b3ad74bcac201be490fe12e4b45adeabc39030ac46f40e1aeb2a20b2f3963e4468e65798d8aaeca1818759cab55ff2b2aa214500aa11571492c3301dd31c1
random-zebra added a commit to PIVX-Project/PIVX that referenced this pull request May 5, 2021
f3f3d6c util: fix compilation with mingw-w64 7.0.0 (Fuzzbawls)
f24da7d util: Avoid potential uninitialized read in FormatISO8601DateTime (Fuzzbawls)
120a12a util: Add type safe GetTime (Fuzzbawls)
be48766 Fix for utiltime to compile with msvc. (Aaron Clauson)
2833406 Avoid std::locale/imbue in DateTimeStrFormat (Pieter Wuille)
3331c25 Format automatic wallet backup file names in ISO 8601 basic format (Fuzzbawls)
c32a208 Format timestamps using ISO 8601 formatting (e.g. "2018-02-28T12:34:56Z") (practicalswift)
f8bd173 [logging] log system time and mock time (John Newbery)

Pull request description:

  This is a backport of a collection of upstream PRs to bring our time utility more up to date. The following upstream PRs are included:

  - bitcoin#10383
  - bitcoin#12567
  - bitcoin#12973
  - bitcoin#13031
  - bitcoin#16046
  - bitcoin#18162
  - bitcoin#18358

  The two user-facing notable changes here have been documented in the release notes template. I've also connected the functionality that `-logtimemicros` was supposed to provide.

ACKs for top commit:
  furszy:
    code review ACK f3f3d6c
  random-zebra:
    utACK f3f3d6c after rebase, and merging...

Tree-SHA512: 64f9cc1f7fc65c192f3b3ab869c057a81e007cf0fae82ecd23993c6b51830e4bc80656c699ba40bb8e019115a24d1ea88a618be0c0d7112749d9ce125d62ce44
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 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.

5 participants