summaryrefslogtreecommitdiff
path: root/libs/gtkmm2ext
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-01-18 18:17:44 +0100
committerRobin Gareus <robin@gareus.org>2020-01-18 18:18:05 +0100
commitd7801ab7eeb9043330fe1e49bac6b40a9cc47b30 (patch)
tree8bba3cf76e56e8266d222b71f7a97743c571ae45 /libs/gtkmm2ext
parent47767738b9aee165a03f09f8ba222179bb73aeb6 (diff)
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.
Diffstat (limited to 'libs/gtkmm2ext')
-rw-r--r--libs/gtkmm2ext/gtk_ui.cc8
1 files changed, 8 insertions, 0 deletions
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<TextBuffer:
{
RefPtr<TextBuffer> 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);