summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-11-27 10:33:20 +0100
committerCarl Hetherington <cth@carlh.net>2025-11-27 10:33:20 +0100
commit574c1a009635e0f9f4d5b653a99f803510761a8d (patch)
treeb8a47788eb2e93a58e75e1217d3c9fb2b541d3e3 /src/lib
parent81dde1a1bec27281dab7b6147d5f8d7deb5a845e (diff)
Log the thread that was used in the encoder (on Linux).
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/encoded_log_entry.cc15
-rw-r--r--src/lib/encoded_log_entry.h3
2 files changed, 16 insertions, 2 deletions
diff --git a/src/lib/encoded_log_entry.cc b/src/lib/encoded_log_entry.cc
index 9a0fe5e49..10c083eaf 100644
--- a/src/lib/encoded_log_entry.cc
+++ b/src/lib/encoded_log_entry.cc
@@ -21,6 +21,9 @@
#include "encoded_log_entry.h"
#include <fmt/format.h>
+#ifdef DCPOMATIC_LINUX
+#include <pthread.h>
+#endif
using std::string;
@@ -34,12 +37,20 @@ EncodedLogEntry::EncodedLogEntry(int frame, string ip, double receive, double en
, _encode(encode)
, _send(send)
{
-
+#ifdef DCPOMATIC_LINUX
+ char name[16];
+ pthread_getname_np(pthread_self(), name, sizeof(name));
+ _thread_name = name;
+#endif
}
string
EncodedLogEntry::message() const
{
- return fmt::format("Encoded frame {} from {}: receive {:.2f}s encode {:.2f}s send {:.2f}s.", _frame, _ip.c_str(), _receive, _encode, _send);
+ string thread_info;
+#ifdef DCPOMATIC_LINUX
+ thread_info = fmt::format(" on {}", _thread_name);
+#endif
+ return fmt::format("Encoded frame {} from {}{}: receive {:.2f}s encode {:.2f}s send {:.2f}s.", _frame, _ip.c_str(), thread_info, _receive, _encode, _send);
}
diff --git a/src/lib/encoded_log_entry.h b/src/lib/encoded_log_entry.h
index 38622f305..5acc84607 100644
--- a/src/lib/encoded_log_entry.h
+++ b/src/lib/encoded_log_entry.h
@@ -35,4 +35,7 @@ private:
double _receive;
double _encode;
double _send;
+#ifdef DCPOMATIC_LINUX
+ std::string _thread_name;
+#endif
};