summarylogtreecommitdiffstats
path: root/ps-log_messages_all.patch
blob: 045f1d963a9e2077fbb491235e9355bedab63231 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
--- a/src/core/manager.cc	2017-04-30 20:32:33.000000000 +0100
+++ b/src/core/manager.cc	2018-04-20 15:45:33.380910446 +0100
@@ -36,6 +36,7 @@
 
 #include "config.h"
 
+#include <ctime>
 #include <cstdio>
 #include <cstring>
 #include <fstream>
@@ -83,6 +84,22 @@ void
 Manager::push_log(const char* msg) {
   m_log_important->lock_and_push_log(msg, strlen(msg), 0);
   m_log_complete->lock_and_push_log(msg, strlen(msg), 0);
+
+  extern int log_messages_fd;
+  if (log_messages_fd >= 0) {
+    char buf[30];
+    time_t t = std::time(0);
+    std::tm* now = std::localtime(&t);
+
+    snprintf(buf, sizeof(buf), "%04u-%02u-%02u %2d:%02d:%02d ",
+        1900 + now->tm_year, now->tm_mon + 1, now->tm_mday,
+        now->tm_hour, now->tm_min, now->tm_sec);
+
+    std::string line(buf);
+    line += msg;
+    line += '\n';
+    ::write(log_messages_fd, line.c_str(), line.length());
+  }
 }
 
 Manager::Manager() :