All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtiofsd: use g_date_time_get_microsecond to get subsecond
@ 2022-08-18 18:46 ` Yusuke Okada
  0 siblings, 0 replies; 11+ messages in thread
From: Yusuke Okada @ 2022-08-18 18:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Yusuke Okada, Dr. David Alan Gilbert, Stefan Hajnoczi,
	open list:virtiofs

From: Yusuke Okada <okada.yusuke@jp.fujitsu.com>

The "%f" specifier in g_date_time_format() is only available in glib
2.65.2 or later. If combined with older glib, the function returns null
and the timestamp displayed as "(null)".

For backward compatibility, g_date_time_get_microsecond should be used
to retrieve subsecond.

In this patch the g_date_time_format() leaves subsecond field as "%06d"
and let next snprintf to format with g_date_time_get_microsecond.

Signed-off-by: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
---
 tools/virtiofsd/passthrough_ll.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index 371a7bead6..20f0f41f99 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -4185,6 +4185,7 @@ static void setup_nofile_rlimit(unsigned long rlimit_nofile)
 static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
 {
     g_autofree char *localfmt = NULL;
+    char buf[64];
 
     if (current_log_level < level) {
         return;
@@ -4197,9 +4198,11 @@ static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
                                        fmt);
         } else {
             g_autoptr(GDateTime) now = g_date_time_new_now_utc();
-            g_autofree char *nowstr = g_date_time_format(now, "%Y-%m-%d %H:%M:%S.%f%z");
+            g_autofree char *nowstr = g_date_time_format(now,
+                                       "%Y-%m-%d %H:%M:%S.%%06d%z");
+            snprintf(buf, 64, nowstr, g_date_time_get_microsecond(now));
             localfmt = g_strdup_printf("[%s] [ID: %08ld] %s",
-                                       nowstr, syscall(__NR_gettid), fmt);
+                                       buf, syscall(__NR_gettid), fmt);
         }
         fmt = localfmt;
     }
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Virtio-fs] [PATCH] virtiofsd: use g_date_time_get_microsecond to get subsecond
@ 2022-08-18 18:46 ` Yusuke Okada
  0 siblings, 0 replies; 11+ messages in thread
From: Yusuke Okada @ 2022-08-18 18:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Yusuke Okada, Dr. David Alan Gilbert, Stefan Hajnoczi,
	open list:virtiofs

From: Yusuke Okada <okada.yusuke@jp.fujitsu.com>

The "%f" specifier in g_date_time_format() is only available in glib
2.65.2 or later. If combined with older glib, the function returns null
and the timestamp displayed as "(null)".

For backward compatibility, g_date_time_get_microsecond should be used
to retrieve subsecond.

In this patch the g_date_time_format() leaves subsecond field as "%06d"
and let next snprintf to format with g_date_time_get_microsecond.

Signed-off-by: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
---
 tools/virtiofsd/passthrough_ll.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index 371a7bead6..20f0f41f99 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -4185,6 +4185,7 @@ static void setup_nofile_rlimit(unsigned long rlimit_nofile)
 static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
 {
     g_autofree char *localfmt = NULL;
+    char buf[64];
 
     if (current_log_level < level) {
         return;
@@ -4197,9 +4198,11 @@ static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
                                        fmt);
         } else {
             g_autoptr(GDateTime) now = g_date_time_new_now_utc();
-            g_autofree char *nowstr = g_date_time_format(now, "%Y-%m-%d %H:%M:%S.%f%z");
+            g_autofree char *nowstr = g_date_time_format(now,
+                                       "%Y-%m-%d %H:%M:%S.%%06d%z");
+            snprintf(buf, 64, nowstr, g_date_time_get_microsecond(now));
             localfmt = g_strdup_printf("[%s] [ID: %08ld] %s",
-                                       nowstr, syscall(__NR_gettid), fmt);
+                                       buf, syscall(__NR_gettid), fmt);
         }
         fmt = localfmt;
     }
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [Virtio-fs] [PATCH] virtiofsd: use g_date_time_get_microsecond to get subsecond
  2022-08-18 18:46 ` [Virtio-fs] " Yusuke Okada
  (?)
@ 2022-08-18 19:12 ` okada.yusuke
  -1 siblings, 0 replies; 11+ messages in thread
From: okada.yusuke @ 2022-08-18 19:12 UTC (permalink / raw)
  To: Yusuke Okada, qemu-devel
  Cc: Dr. David Alan Gilbert, Stefan Hajnoczi, open list:virtiofs

Hi,

Because the first mail doesn't include "From" line in its body, I sent it again.
Sorry for bothering.

Best Regards,
Yusuke Okada



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] virtiofsd: use g_date_time_get_microsecond to get subsecond
  2022-08-18 18:46 ` [Virtio-fs] " Yusuke Okada
@ 2022-08-24 11:05   ` Dr. David Alan Gilbert
  -1 siblings, 0 replies; 11+ messages in thread
From: Dr. David Alan Gilbert @ 2022-08-24 11:05 UTC (permalink / raw)
  To: Yusuke Okada, berrange, marcandre.lureau
  Cc: qemu-devel, Yusuke Okada, Stefan Hajnoczi, open list:virtiofs

* Yusuke Okada (yokada.996@gmail.com) wrote:
> From: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
> 
> The "%f" specifier in g_date_time_format() is only available in glib
> 2.65.2 or later. If combined with older glib, the function returns null
> and the timestamp displayed as "(null)".

Well spotted; thanks for the patch.
I notice there's also a use in rocker and qga (Copying Dan and
Marc-Andre in who added them)

> For backward compatibility, g_date_time_get_microsecond should be used
> to retrieve subsecond.
> 
> In this patch the g_date_time_format() leaves subsecond field as "%06d"
> and let next snprintf to format with g_date_time_get_microsecond.
> 
> Signed-off-by: Yusuke Okada <okada.yusuke@jp.fujitsu.com>


Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  tools/virtiofsd/passthrough_ll.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
> index 371a7bead6..20f0f41f99 100644
> --- a/tools/virtiofsd/passthrough_ll.c
> +++ b/tools/virtiofsd/passthrough_ll.c
> @@ -4185,6 +4185,7 @@ static void setup_nofile_rlimit(unsigned long rlimit_nofile)
>  static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
>  {
>      g_autofree char *localfmt = NULL;
> +    char buf[64];
>  
>      if (current_log_level < level) {
>          return;
> @@ -4197,9 +4198,11 @@ static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
>                                         fmt);
>          } else {
>              g_autoptr(GDateTime) now = g_date_time_new_now_utc();
> -            g_autofree char *nowstr = g_date_time_format(now, "%Y-%m-%d %H:%M:%S.%f%z");
> +            g_autofree char *nowstr = g_date_time_format(now,
> +                                       "%Y-%m-%d %H:%M:%S.%%06d%z");
> +            snprintf(buf, 64, nowstr, g_date_time_get_microsecond(now));
>              localfmt = g_strdup_printf("[%s] [ID: %08ld] %s",
> -                                       nowstr, syscall(__NR_gettid), fmt);
> +                                       buf, syscall(__NR_gettid), fmt);
>          }
>          fmt = localfmt;
>      }
> -- 
> 2.31.1
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Virtio-fs] [PATCH] virtiofsd: use g_date_time_get_microsecond to get subsecond
@ 2022-08-24 11:05   ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 11+ messages in thread
From: Dr. David Alan Gilbert @ 2022-08-24 11:05 UTC (permalink / raw)
  To: Yusuke Okada, berrange, marcandre.lureau
  Cc: qemu-devel, Yusuke Okada, Stefan Hajnoczi, open list:virtiofs

* Yusuke Okada (yokada.996@gmail.com) wrote:
> From: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
> 
> The "%f" specifier in g_date_time_format() is only available in glib
> 2.65.2 or later. If combined with older glib, the function returns null
> and the timestamp displayed as "(null)".

Well spotted; thanks for the patch.
I notice there's also a use in rocker and qga (Copying Dan and
Marc-Andre in who added them)

> For backward compatibility, g_date_time_get_microsecond should be used
> to retrieve subsecond.
> 
> In this patch the g_date_time_format() leaves subsecond field as "%06d"
> and let next snprintf to format with g_date_time_get_microsecond.
> 
> Signed-off-by: Yusuke Okada <okada.yusuke@jp.fujitsu.com>


Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  tools/virtiofsd/passthrough_ll.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
> index 371a7bead6..20f0f41f99 100644
> --- a/tools/virtiofsd/passthrough_ll.c
> +++ b/tools/virtiofsd/passthrough_ll.c
> @@ -4185,6 +4185,7 @@ static void setup_nofile_rlimit(unsigned long rlimit_nofile)
>  static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
>  {
>      g_autofree char *localfmt = NULL;
> +    char buf[64];
>  
>      if (current_log_level < level) {
>          return;
> @@ -4197,9 +4198,11 @@ static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
>                                         fmt);
>          } else {
>              g_autoptr(GDateTime) now = g_date_time_new_now_utc();
> -            g_autofree char *nowstr = g_date_time_format(now, "%Y-%m-%d %H:%M:%S.%f%z");
> +            g_autofree char *nowstr = g_date_time_format(now,
> +                                       "%Y-%m-%d %H:%M:%S.%%06d%z");
> +            snprintf(buf, 64, nowstr, g_date_time_get_microsecond(now));
>              localfmt = g_strdup_printf("[%s] [ID: %08ld] %s",
> -                                       nowstr, syscall(__NR_gettid), fmt);
> +                                       buf, syscall(__NR_gettid), fmt);
>          }
>          fmt = localfmt;
>      }
> -- 
> 2.31.1
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] virtiofsd: use g_date_time_get_microsecond to get subsecond
  2022-08-18 18:46 ` [Virtio-fs] " Yusuke Okada
@ 2022-08-24 17:41   ` Stefan Hajnoczi
  -1 siblings, 0 replies; 11+ messages in thread
From: Stefan Hajnoczi @ 2022-08-24 17:41 UTC (permalink / raw)
  To: Yusuke Okada
  Cc: qemu-devel, Yusuke Okada, Dr. David Alan Gilbert, open list:virtiofs

[-- Attachment #1: Type: text/plain, Size: 843 bytes --]

On Thu, Aug 18, 2022 at 02:46:19PM -0400, Yusuke Okada wrote:
> From: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
> 
> The "%f" specifier in g_date_time_format() is only available in glib
> 2.65.2 or later. If combined with older glib, the function returns null
> and the timestamp displayed as "(null)".
> 
> For backward compatibility, g_date_time_get_microsecond should be used
> to retrieve subsecond.
> 
> In this patch the g_date_time_format() leaves subsecond field as "%06d"
> and let next snprintf to format with g_date_time_get_microsecond.
> 
> Signed-off-by: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
> ---
>  tools/virtiofsd/passthrough_ll.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)

Thanks, applied to my block tree for QEMU 7.2:
https://gitlab.com/stefanha/qemu/commits/block

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Virtio-fs] [PATCH] virtiofsd: use g_date_time_get_microsecond to get subsecond
@ 2022-08-24 17:41   ` Stefan Hajnoczi
  0 siblings, 0 replies; 11+ messages in thread
From: Stefan Hajnoczi @ 2022-08-24 17:41 UTC (permalink / raw)
  To: Yusuke Okada
  Cc: qemu-devel, Yusuke Okada, Dr. David Alan Gilbert, open list:virtiofs

[-- Attachment #1: Type: text/plain, Size: 843 bytes --]

On Thu, Aug 18, 2022 at 02:46:19PM -0400, Yusuke Okada wrote:
> From: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
> 
> The "%f" specifier in g_date_time_format() is only available in glib
> 2.65.2 or later. If combined with older glib, the function returns null
> and the timestamp displayed as "(null)".
> 
> For backward compatibility, g_date_time_get_microsecond should be used
> to retrieve subsecond.
> 
> In this patch the g_date_time_format() leaves subsecond field as "%06d"
> and let next snprintf to format with g_date_time_get_microsecond.
> 
> Signed-off-by: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
> ---
>  tools/virtiofsd/passthrough_ll.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)

Thanks, applied to my block tree for QEMU 7.2:
https://gitlab.com/stefanha/qemu/commits/block

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Virtio-fs] [PATCH] virtiofsd: use g_date_time_get_microsecond to get subsecond
  2022-08-24 17:41   ` [Virtio-fs] " Stefan Hajnoczi
  (?)
@ 2022-09-20 17:58   ` Vivek Goyal
  2022-09-27 15:50     ` Stefan Hajnoczi
  -1 siblings, 1 reply; 11+ messages in thread
From: Vivek Goyal @ 2022-09-20 17:58 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: Yusuke Okada, open list:virtiofs, Yusuke Okada, qemu-devel

On Wed, Aug 24, 2022 at 01:41:29PM -0400, Stefan Hajnoczi wrote:
> On Thu, Aug 18, 2022 at 02:46:19PM -0400, Yusuke Okada wrote:
> > From: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
> > 
> > The "%f" specifier in g_date_time_format() is only available in glib
> > 2.65.2 or later. If combined with older glib, the function returns null
> > and the timestamp displayed as "(null)".
> > 
> > For backward compatibility, g_date_time_get_microsecond should be used
> > to retrieve subsecond.
> > 
> > In this patch the g_date_time_format() leaves subsecond field as "%06d"
> > and let next snprintf to format with g_date_time_get_microsecond.
> > 
> > Signed-off-by: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
> > ---
> >  tools/virtiofsd/passthrough_ll.c | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> Thanks, applied to my block tree for QEMU 7.2:
> https://gitlab.com/stefanha/qemu/commits/block

Hi Stefan,

Wondering when do you plan to send it for merge. This seems like
a simple fix. Not sure why it does not qualify as a fix for
7.1 instead.

Thanks
Vivek

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Virtio-fs] [PATCH] virtiofsd: use g_date_time_get_microsecond to get subsecond
  2022-09-20 17:58   ` Vivek Goyal
@ 2022-09-27 15:50     ` Stefan Hajnoczi
  0 siblings, 0 replies; 11+ messages in thread
From: Stefan Hajnoczi @ 2022-09-27 15:50 UTC (permalink / raw)
  To: Vivek Goyal
  Cc: Stefan Hajnoczi, Yusuke Okada, open list:virtiofs, Yusuke Okada,
	qemu-devel, qemu-stable

On Tue, 20 Sept 2022 at 19:08, Vivek Goyal <vgoyal@redhat.com> wrote:
>
> On Wed, Aug 24, 2022 at 01:41:29PM -0400, Stefan Hajnoczi wrote:
> > On Thu, Aug 18, 2022 at 02:46:19PM -0400, Yusuke Okada wrote:
> > > From: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
> > >
> > > The "%f" specifier in g_date_time_format() is only available in glib
> > > 2.65.2 or later. If combined with older glib, the function returns null
> > > and the timestamp displayed as "(null)".
> > >
> > > For backward compatibility, g_date_time_get_microsecond should be used
> > > to retrieve subsecond.
> > >
> > > In this patch the g_date_time_format() leaves subsecond field as "%06d"
> > > and let next snprintf to format with g_date_time_get_microsecond.
> > >
> > > Signed-off-by: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
> > > ---
> > >  tools/virtiofsd/passthrough_ll.c | 7 +++++--
> > >  1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > Thanks, applied to my block tree for QEMU 7.2:
> > https://gitlab.com/stefanha/qemu/commits/block
>
> Hi Stefan,
>
> Wondering when do you plan to send it for merge. This seems like
> a simple fix. Not sure why it does not qualify as a fix for
> 7.1 instead.

The pull request with this patch was merged into qemu.git/master today.

Regarding 7.1, it needs to go through the -stable tree. I have CCed
qemu-stable so this patch can be picked up.

Thanks,
Stefan


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Virtio-fs] [PATCH] virtiofsd: use g_date_time_get_microsecond to get subsecond
  2022-08-18 17:46 Yusuke Okada
@ 2022-08-19  1:47 ` liuyd.fnst
  0 siblings, 0 replies; 11+ messages in thread
From: liuyd.fnst @ 2022-08-19  1:47 UTC (permalink / raw)
  To: Yusuke Okada, qemu-devel; +Cc: open list:virtiofs, okada.yusuke

It works. I tested on RHEL8
Before this fix:
```
# /root/qemu/build/tools/virtiofsd/virtiofsd --socket-path=/tmp/sock -o 
source=/home/test -d

[(null)] [ID: 00133152] virtio_session_mount: Waiting for vhost-user 
socket connection...


```

After applying this patch
```
# /root/qemu/build/tools/virtiofsd/virtiofsd --socket-path=/tmp/sock -o 
source=/home/test -d

[2022-08-19 01:45:41.981608+0000] [ID: 00134587] virtio_session_mount: 
Waiting for vhost-user socket connection...

```	


On 8/19/22 01:46, Yusuke Okada wrote:
> The "%f" specifier in g_date_time_format() is only available in glib
> 2.65.2 or later. If combined with older glib, the function returns null
> and the timestamp displayed as "(null)".
> 
> For backward compatibility, g_date_time_get_microsecond should be used
> to retrieve subsecond.
> 
> In this patch the g_date_time_format() leaves subsecond field as "%06d"
> and let next snprintf to format with g_date_time_get_microsecond.
> 
> Signed-off-by: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
> ---
>   tools/virtiofsd/passthrough_ll.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
> index 371a7bead6..20f0f41f99 100644
> --- a/tools/virtiofsd/passthrough_ll.c
> +++ b/tools/virtiofsd/passthrough_ll.c
> @@ -4185,6 +4185,7 @@ static void setup_nofile_rlimit(unsigned long rlimit_nofile)
>   static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
>   {
>       g_autofree char *localfmt = NULL;
> +    char buf[64];
>   
>       if (current_log_level < level) {
>           return;
> @@ -4197,9 +4198,11 @@ static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
>                                          fmt);
>           } else {
>               g_autoptr(GDateTime) now = g_date_time_new_now_utc();
> -            g_autofree char *nowstr = g_date_time_format(now, "%Y-%m-%d %H:%M:%S.%f%z");
> +            g_autofree char *nowstr = g_date_time_format(now,
> +                                       "%Y-%m-%d %H:%M:%S.%%06d%z");
> +            snprintf(buf, 64, nowstr, g_date_time_get_microsecond(now));
>               localfmt = g_strdup_printf("[%s] [ID: %08ld] %s",
> -                                       nowstr, syscall(__NR_gettid), fmt);
> +                                       buf, syscall(__NR_gettid), fmt);
>           }
>           fmt = localfmt;
>       }

-- 
Thanks,
Yiding

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Virtio-fs] [PATCH] virtiofsd: use g_date_time_get_microsecond to get subsecond
@ 2022-08-18 17:46 Yusuke Okada
  2022-08-19  1:47 ` liuyd.fnst
  0 siblings, 1 reply; 11+ messages in thread
From: Yusuke Okada @ 2022-08-18 17:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Yusuke Okada, Dr. David Alan Gilbert, Stefan Hajnoczi,
	open list:virtiofs

The "%f" specifier in g_date_time_format() is only available in glib
2.65.2 or later. If combined with older glib, the function returns null
and the timestamp displayed as "(null)".

For backward compatibility, g_date_time_get_microsecond should be used
to retrieve subsecond.

In this patch the g_date_time_format() leaves subsecond field as "%06d"
and let next snprintf to format with g_date_time_get_microsecond.

Signed-off-by: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
---
 tools/virtiofsd/passthrough_ll.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index 371a7bead6..20f0f41f99 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -4185,6 +4185,7 @@ static void setup_nofile_rlimit(unsigned long rlimit_nofile)
 static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
 {
     g_autofree char *localfmt = NULL;
+    char buf[64];
 
     if (current_log_level < level) {
         return;
@@ -4197,9 +4198,11 @@ static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
                                        fmt);
         } else {
             g_autoptr(GDateTime) now = g_date_time_new_now_utc();
-            g_autofree char *nowstr = g_date_time_format(now, "%Y-%m-%d %H:%M:%S.%f%z");
+            g_autofree char *nowstr = g_date_time_format(now,
+                                       "%Y-%m-%d %H:%M:%S.%%06d%z");
+            snprintf(buf, 64, nowstr, g_date_time_get_microsecond(now));
             localfmt = g_strdup_printf("[%s] [ID: %08ld] %s",
-                                       nowstr, syscall(__NR_gettid), fmt);
+                                       buf, syscall(__NR_gettid), fmt);
         }
         fmt = localfmt;
     }
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-09-27 15:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-18 18:46 [PATCH] virtiofsd: use g_date_time_get_microsecond to get subsecond Yusuke Okada
2022-08-18 18:46 ` [Virtio-fs] " Yusuke Okada
2022-08-18 19:12 ` okada.yusuke
2022-08-24 11:05 ` Dr. David Alan Gilbert
2022-08-24 11:05   ` [Virtio-fs] " Dr. David Alan Gilbert
2022-08-24 17:41 ` Stefan Hajnoczi
2022-08-24 17:41   ` [Virtio-fs] " Stefan Hajnoczi
2022-09-20 17:58   ` Vivek Goyal
2022-09-27 15:50     ` Stefan Hajnoczi
  -- strict thread matches above, loose matches on Subject: below --
2022-08-18 17:46 Yusuke Okada
2022-08-19  1:47 ` liuyd.fnst

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.