After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 769846 - gmessages: Add timestamp to g_log_writer_format_fields()
gmessages: Add timestamp to g_log_writer_format_fields()
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2016-08-13 15:36 UTC by Philip Withnall
Modified: 2017-11-03 13:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gmessages: Add timestamp to g_log_writer_format_fields() (1.95 KB, patch)
2016-08-13 15:36 UTC, Philip Withnall
committed Details | Review

Description Philip Withnall 2016-08-13 15:36:01 UTC
Trivial patch attached.
Comment 1 Philip Withnall 2016-08-13 15:36:04 UTC
Created attachment 333237 [details] [review]
gmessages: Add timestamp to g_log_writer_format_fields()

Since journald adds a timestamp, it would be useful to add one to the
stdout/stderr output too — we do not want it to miss out on the
timestamping fun.

Make it blue, because we can.
Comment 2 Emmanuele Bassi (:ebassi) 2017-10-06 10:01:17 UTC
Review of attachment 333237 [details] [review]:

This looks good, but I find myself often in need of the time elapsed since the last message (within a second) instead of the absolute time stamp — like the kernel log does.

I've implemented this in Clutter ages ago: https://git.gnome.org/browse/clutter/tree/clutter/clutter-main.c#n3714

It's very useful when you have a lot of events coming in within a few milliseconds, and you don't want to do the math in your head.
Comment 3 Philip Withnall 2017-10-06 10:29:45 UTC
Review of attachment 333237 [details] [review]:

Seems like a reasonable thing to do. If people want the full timestamp, they can work it out or extract it from the relevant field in the journal.
Comment 4 Philip Withnall 2017-11-03 13:00:12 UTC
(In reply to Philip Withnall from comment #3)
> Review of attachment 333237 [details] [review] [review]:
> 
> Seems like a reasonable thing to do. If people want the full timestamp, they
> can work it out or extract it from the relevant field in the journal.

…except that g_log_writer_format_fields() is a public function, and might be called 0…n times per log message (if a single message is output in several different ways, or is formatted and then dropped later on). That’s not a problem with the default writer function (g_log_writer_default()), but could easily become a problem if people were to use g_log_writer_format_fields() from their own, more-complex writer functions.

For that reason I’m going to stick with the existing, non-delta-based patch. The few use cases like Clutter where a delta-based approach is really useful can provide their own formatting functions.
Comment 5 Philip Withnall 2017-11-03 13:01:57 UTC
Attachment 333237 [details] pushed as a6fc4da - gmessages: Add timestamp to g_log_writer_format_fields()