For completeness, the following comments were given in ReviewBoard:
This change allows unformatted high-resolution timestamps to replace the normal 1-second resolution formatted date/time timestamps in the log files for debug situations where looking at the elapsed time between events might be useful. If many events occur within the same second, then the standard resolution timestamps are unhelpful. The idea is to uncomment the #define and compile in the high-res timestamps when needed, but to leave the #define commented out for normal use.
Ahhh - where was this last week when I could've really used it? Good idea!
Why not make this a runtime option enabled with --log-highres-timestamp? The cost of a simple "if (highresTimestampsEnabled)" isn't high compared to all the formatting. Then this could be turned on without a rebuild, so could be used by consultants in the field etc.
I replied in the JIRA that the compile-time switch should be set in cmake/autoconf, but I like Alan's run-time idea more. However, I think it would be better if the run-time decision was made at the caller of this (call a high-res formatted time rather than the regular one). Then it would be immediately clear if a platform forgets to define the high-res code - it would break at build time - and the decision is made in platform-neutral code so it's always uniform in the documentation and run-time handling.
Kim van der Riet:
<Added new patch>
Thanks for the comments. Here is a version that defines a logging option --log-hires-timestamp, and behaves as follows:
./qpidd --auth no --log-enable info+ --log-hires-timestamp yes
1304105003.833914147s info Management enabled
1304105003.834060811s info ManagementAgent restored broker ID: 07133ede-bda4-4c3f-a649-e39007c83e98
1304105003.834542359s notice SASL disabled: No Authentication Performed
1304105003.834659341s notice Listening on TCP port 5672
1304105003.834785542s notice Broker running
^C1304105017.576632384s notice Shut down
As Steve suggested, the function that formats this version is a separate function outputHiresNow(). Steve, I have not added this to the windows version, but I assume that it will work the same as it uses only std::ostream and iomanip functions. Can you verify?
I like it. Nice work.
If someone can plug in the Windows code, that would be great! I'm not going to be able to get to it until at least next Tuesday.