GNOME Bugzilla – Bug 769846
gmessages: Add timestamp to g_log_writer_format_fields()
Last modified: 2017-11-03 13:02:01 UTC
Trivial patch attached.
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.
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.
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.
(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.
Attachment 333237 [details] pushed as a6fc4da - gmessages: Add timestamp to g_log_writer_format_fields()