On Fri, 19 Sep 2025 07:02:35 GMT, Alan Bateman <[email protected]> wrote:

>> `jcmd` provides great diagnostics but many commands lack a timestamp in 
>> their output.
>> Adding a timestamp to the output of some would add value for those debugging 
>> JVM data.
>> 
>> Some diagnostic commands already provide timestamps. For example 
>> `Thread.print` already prints timestamp in a "yyyy-MM-dd HH:mm:ss" format.
>> 
>> Adding timestamps to all diagnostic `jcmd` commands with a non-throw-away 
>> STDOUT.
>> 
>> The exceptions are:
>> * `VM.uptime` - command run with `-date` argument will also print a 
>> timestamp;
>> * `VM.system_properties` - already lists timestamp
>> * `Thread.dump_to_file` - the content dumped to file already has a timestamp;
>> * `VM.version`
>
> src/hotspot/share/services/diagnosticCommand.cpp line 1093:
> 
>> 1091: 
>> 1092: void ThreadDumpToFileDCmd::execute(DCmdSource source, TRAPS) {
>> 1093:   print_local_time(output());
> 
> I assume you didn't mean to print a time stamp here as the output already has 
> a timestamp. Also for -format=json and sending the output to stdout, then it 
> will be unparsable if a timestamp appears before the JSON object.

Hi Alan. That's right.
My mistake. I declared the intention to not have timestamps for commands with a 
throwaway `stdout`. This also includes "Thread.dump_to_file" command but then 
mistakenly added `print_local_time()` in here.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/27368#discussion_r2362306527

Reply via email to