-
Notifications
You must be signed in to change notification settings - Fork 36.5k
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
Debug: Add option for microsecond precision in debug.log #6881
Conversation
Thanks for picking it up, not sure why the other got closed. |
Concept ACK. I'd really like the higher precision. |
/** Return a time useful for the debug log */ | ||
int64_t GetLogTimeMicros() | ||
{ | ||
if (nMockTime) return nMockTime*1000000; |
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.
Do we really care about mock times for debug log entires?
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.
I think we should, as if we ever give a way to change the mocktime via RPC it'd be useful to be able to correlate the log files to what time we set.
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.
Yeah I have some code I use to test that plays back historical data to a node and uses mocktime, and having the debug log have (mostly) consistent timestamps is helpful to me, so I figured I'd preserve the existing behavior.
Concept ACK - can be useful. Do keep it disabled by default, high-precision time makes correlation/side channel attacks easier, better to not make the logs more valuable. |
@@ -726,6 +727,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) | |||
// Set this early so that parameter interactions go to console | |||
fPrintToConsole = GetBoolArg("-printtoconsole", false); | |||
fLogTimestamps = GetBoolArg("-logtimestamps", true); | |||
fLogTimeMicros = GetBoolArg("-logtimemicros", false); |
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: Can you use the already present fLogTimeMicros
which defaults to false instead of hardcoding it twice? (c.f. #6349)
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.
Good idea; fixed.
Concept ACK |
a606db3
to
fc099a3
Compare
ACK, works as advertised |
GetTimeMicros() is not a monotone clock. Will doom befall our users when the log entry timestamps sometimes go backwards? |
@@ -726,6 +727,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) | |||
// Set this early so that parameter interactions go to console | |||
fPrintToConsole = GetBoolArg("-printtoconsole", false); | |||
fLogTimestamps = GetBoolArg("-logtimestamps", true); | |||
fLogTimeMicros = GetBoolArg("-logtimemicros", fLogTimeMicros); |
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.
Instead of passing fLogTimeMicros both as input and output I'd prefer the default to be handled like the others, e.g. in the header,
static const bool DEFAULT_LOGTIMEMICROS = false;
Then
strUsage += HelpMessageOpt("-logtimemicros", strprintf("Add microsecond precision to debug timestamps (default: %u)", DEFAULT_LOGTIMEMICROS));
...
LogTimeMicros = GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS);
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.
Will do -- is that fine to put in util.h, since the global is declared in util.cpp? (I don't see anything else like that in util.h, so just want to double-check.)
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.
Yep, sounds good to me. You're right that the other options in util.h don't stick to this either, but it's the sane thing to do for new options :)
@gmaxwell |
fc099a3
to
7bbc7c3
Compare
ut ACK - though I do not see value in making this yet another option IMO just add micros to the log and be done with it. |
@laanwj There are other ways to make the time monotone-- apply max with the last priinted time. (OS returned monotone time can also be adjusted to whatever timebase by finding the initial offset; but that goes down a rabbit hole). WRT Jeff's comment. I too would rather have them on all the time, and any message where we're worried about creating privacy violating logs, we should just stop logging them by default-- they're probably already problematic with 1 second times. (I'm not sure which messages these would be as I don't currently have any nodes without debugging turned up!) |
7bbc7c3 Add option for microsecond precision in debug.log (Suhas Daftuar)
Would really like to keep this an option, so will merge as-is. |
@laanwj Justification? More options = more work. Where is the value in yet another default-off option that few users will ever know about, much less use? Default-off this is basically dead code we must maintain. |
See my post above. |
@laanwj "no need for microsecond timestamps for most people" Citation needed? Apache, MySQL, Linux kernel, several sys-loggers and other major servers/services moved to sub-second timestamps a while ago. |
FWIW I've never even needed second-precision timestamps myself. Equally, dmesg for example gives me "seconds since boot" or something, rather than what I usually am more interested in, the date - wouldn't use that as an example of user friendly for general debugging. |
Github-Pull: bitcoin#6881 Rebased-From: 7bbc7c3
(Inspired by #6880)