aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/server/common
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-06-13 22:40:22 +0200
committerEgor Tensin <egor@tensin.name>2026-06-13 22:40:22 +0200
commit567b2eabe35a72499bb5dd81f7dcbeebc3737234 (patch)
treedd17eb6e279ee54e17cad964bbb3ed9a7246d34f /server/common
parentuse std:: facilities for timestamp formatting (diff)
downloadmath-server-567b2eabe35a72499bb5dd81f7dcbeebc3737234.tar.gz
math-server-567b2eabe35a72499bb5dd81f7dcbeebc3737234.zip
log: print actual thread IDs
Diffstat (limited to 'server/common')
-rw-r--r--server/common/log.hpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/server/common/log.hpp b/server/common/log.hpp
index 573590b..2d1dba5 100644
--- a/server/common/log.hpp
+++ b/server/common/log.hpp
@@ -7,11 +7,16 @@
#include <boost/system/error_code.hpp>
+#ifdef WIN32
+#include <windows.h>
+#else
+#include <unistd.h>
+#endif
+
#include <exception>
#include <format>
#include <iomanip>
#include <iostream>
-#include <sstream>
#include <string>
#include <string_view>
#include <thread>
@@ -20,10 +25,12 @@
namespace math::server::log {
namespace details {
-inline std::string get_tid() {
- std::ostringstream oss;
- oss << std::this_thread::get_id();
- return oss.str();
+inline std::size_t get_tid() {
+#ifdef WIN32
+ return GetCurrentThreadId();
+#else
+ return gettid();
+#endif
}
inline std::string get_timestamp() {