* [PATCH] trace: log.py: human-readable timestamp
@ 2025-06-26 19:55 Vladimir Sementsov-Ogievskiy
2025-06-29 10:58 ` Stefan Hajnoczi
0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2025-06-26 19:55 UTC (permalink / raw)
To: qemu-devel; +Cc: mads, stefanha, vsementsov
So tired to parse all these timestamps, when need to compare them
with other logs.
Use iso8601 format as in warn_report() (info_report(), error_report())
already used.
Also, start line with date, to be similar with warn_report() as well.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
scripts/tracetool/backend/log.py | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/log.py
index 17ba1cd90eb..61118474b16 100644
--- a/scripts/tracetool/backend/log.py
+++ b/scripts/tracetool/backend/log.py
@@ -39,10 +39,15 @@ def generate_h(event, group):
' if (message_with_timestamp) {',
' struct timeval _now;',
' gettimeofday(&_now, NULL);',
+ ' time_t _seconds = _now.tv_sec;',
+ ' struct tm _tm;',
+ ' gmtime_r(&_seconds, &_tm);',
'#line %(event_lineno)d "%(event_filename)s"',
- ' qemu_log("%%d@%%zu.%%06zu:%(name)s " %(fmt)s "\\n",',
- ' qemu_get_thread_id(),',
- ' (size_t)_now.tv_sec, (size_t)_now.tv_usec',
+ ' qemu_log("%%04d-%%02d-%%02dT%%02d:%%02d:%%02d.%%06ldZ'
+ ' (%%d) %(name)s " %(fmt)s "\\n",',
+ ' _tm.tm_year + 1900, _tm.tm_mon + 1, _tm.tm_mday,',
+ ' _tm.tm_hour, _tm.tm_min, _tm.tm_sec, _now.tv_usec,',
+ ' qemu_get_thread_id()',
' %(argnames)s);',
'#line %(out_next_lineno)d "%(out_filename)s"',
' } else {',
--
2.48.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] trace: log.py: human-readable timestamp
2025-06-26 19:55 [PATCH] trace: log.py: human-readable timestamp Vladimir Sementsov-Ogievskiy
@ 2025-06-29 10:58 ` Stefan Hajnoczi
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2025-06-29 10:58 UTC (permalink / raw)
To: Vladimir Sementsov-Ogievskiy; +Cc: qemu-devel, mads
[-- Attachment #1: Type: text/plain, Size: 631 bytes --]
On Thu, Jun 26, 2025 at 10:55:14PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> So tired to parse all these timestamps, when need to compare them
> with other logs.
>
> Use iso8601 format as in warn_report() (info_report(), error_report())
> already used.
>
> Also, start line with date, to be similar with warn_report() as well.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
> scripts/tracetool/backend/log.py | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
Thanks, applied to my tracing tree:
https://gitlab.com/stefanha/qemu/commits/tracing
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-29 13:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-26 19:55 [PATCH] trace: log.py: human-readable timestamp Vladimir Sementsov-Ogievskiy
2025-06-29 10:58 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).