diff options
| author | Egor Tensin <egor@tensin.name> | 2026-06-13 22:40:22 +0200 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-06-13 22:40:22 +0200 |
| commit | 567b2eabe35a72499bb5dd81f7dcbeebc3737234 (patch) | |
| tree | dd17eb6e279ee54e17cad964bbb3ed9a7246d34f /server/common | |
| parent | use std:: facilities for timestamp formatting (diff) | |
| download | math-server-567b2eabe35a72499bb5dd81f7dcbeebc3737234.tar.gz math-server-567b2eabe35a72499bb5dd81f7dcbeebc3737234.zip | |
log: print actual thread IDs
Diffstat (limited to 'server/common')
| -rw-r--r-- | server/common/log.hpp | 17 |
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() { |
