All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Dongli Zhang <dongli.zhang@oracle.com>
Cc: qemu-devel@nongnu.org,  joe.jin@oracle.com,
	richard.henderson@linaro.org,  alex.bennee@linaro.org,
	 f4bug@amsat.org
Subject: Re: [PATCH 2/2] util/log: add timestamp to logs via qemu_log()
Date: Tue, 30 Aug 2022 13:09:51 +0200	[thread overview]
Message-ID: <87czcihts0.fsf@pond.sub.org> (raw)
In-Reply-To: <20220829100622.1554-2-dongli.zhang@oracle.com> (Dongli Zhang's message of "Mon, 29 Aug 2022 03:06:22 -0700")

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.



  reply	other threads:[~2022-08-30 11:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-29 10:06 [PATCH 1/2] error-report: make real_time_iso8601() non-static Dongli Zhang
2022-08-29 10:06 ` [PATCH 2/2] util/log: add timestamp to logs via qemu_log() Dongli Zhang
2022-08-30 11:09   ` Markus Armbruster [this message]
2022-08-30 15:31     ` Richard Henderson
2022-09-01  4:17       ` Dongli Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87czcihts0.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=dongli.zhang@oracle.com \
    --cc=f4bug@amsat.org \
    --cc=joe.jin@oracle.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.