From d7801ab7eeb9043330fe1e49bac6b40a9cc47b30 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 18 Jan 2020 18:17:44 +0100 Subject: [PATCH] Add timestamp to log -- #7877 This adds the time when a log message is displayed. ARDOUR_UI::display_message() parses the prefix, so the timestamp cannot be prefixed in the beforehand. Still, UI::process_error_message() is called directly in the same thread, so this makes no significant difference. --- libs/gtkmm2ext/gtk_ui.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/gtkmm2ext/gtk_ui.cc b/libs/gtkmm2ext/gtk_ui.cc index 34a6d1f53e..d1e834d892 100644 --- a/libs/gtkmm2ext/gtk_ui.cc +++ b/libs/gtkmm2ext/gtk_ui.cc @@ -36,6 +36,7 @@ #include "pbd/error.h" #include "pbd/touchable.h" #include "pbd/failed_constructor.h" +#include "pbd/localtime_r.h" #include "pbd/pthread_utils.h" #include "pbd/replace_all.h" @@ -643,6 +644,13 @@ UI::display_message (const char *prefix, gint /*prefix_len*/, RefPtr buffer (errors->text().get_buffer()); + char timebuf[128]; + time_t n = time (NULL); + struct tm local_time; + localtime_r (&n, &local_time); + strftime (timebuf, sizeof(timebuf), "%FT%H.%M.%S ", &local_time); + + buffer->insert_with_tag(buffer->end(), timebuf, ptag); buffer->insert_with_tag(buffer->end(), prefix, ptag); buffer->insert_with_tag(buffer->end(), msg, mtag); buffer->insert_with_tag(buffer->end(), "\n", mtag);