[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/2] util/log: add timestamp to logs via qemu_log()
From: |
Markus Armbruster |
Subject: |
Re: [PATCH 2/2] util/log: add timestamp to logs via qemu_log() |
Date: |
Tue, 30 Aug 2022 13:09:51 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) |
Dongli Zhang <dongli.zhang@oracle.com> writes:
> The qemu_log is very helpful for diagnostic. Add the timestamp to the log
> when it is enabled (e.g., "-msg timestamp=on").
>
> While there are many other places that may print to log file, this patch is
> only for qemu_log(), e.g., the developer may add qemu_log/qemu_log_mask to
> selected locations to diagnose QEMU issue.
Opinions on the new feature, anyone?
> Cc: Joe Jin <joe.jin@oracle.com>
> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
> ---
> Please let me know if we should use 'error_with_guestname' as well.
>
> util/log.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/util/log.c b/util/log.c
> index d6eb037..f0a081a 100644
> --- a/util/log.c
> +++ b/util/log.c
> @@ -129,8 +129,15 @@ void qemu_log(const char *fmt, ...)
> {
> FILE *f = qemu_log_trylock();
> if (f) {
> + gchar *timestr;
> va_list ap;
>
> + if (message_with_timestamp) {
> + timestr = real_time_iso8601();
> + fprintf(f, "%s ", timestr);
> + g_free(timestr);
> + }
> +
> va_start(ap, fmt);
> vfprintf(f, fmt, ap);
> va_end(ap);
This extends -msg timestamp=on to apply to log messages without
documenting it in -help or anywhere else. Needs fixing.