commit 1219b52a61799062d495375c71a8ff133dddb04f from: Aleksey Ryndin date: Wed Apr 17 09:06:42 2024 UTC Add thread id logging commit - 70d0dc979f7d264345d4edaac791b46aeb6e380d commit + 1219b52a61799062d495375c71a8ff133dddb04f blob - 4be25cb4c2ff370d6e4ae0174dd272237a97e7fc blob + 6f1452cf12db021a5275739ddaf9a1949d6c9935 --- vostok/vostok.cc +++ vostok/vostok.cc @@ -24,6 +24,22 @@ namespace vostok { namespace { + + +struct LogThreadId +{ + LogThreadId() + { + error::g_log << "+" << std::hex << m_thread_id << " "; + } + ~LogThreadId() + { + error::g_log << "-" << std::hex << m_thread_id << std::endl; + } + + const std::thread::id m_thread_id{std::this_thread::get_id()}; +}; + namespace meta { @@ -64,17 +80,19 @@ void put_time_prefix() struct tm converted{}; gmtime_r(&t, &converted); error::g_log - << std::setw(2) << std::setfill('0') << converted.tm_hour + << std::dec << std::setw(2) << std::setfill('0') << converted.tm_hour << ":" - << std::setw(2) << std::setfill('0') << converted.tm_min + << std::dec << std::setw(2) << std::setfill('0') << converted.tm_min << ":" - << std::setw(2) << std::setfill('0') << converted.tm_sec + << std::dec << std::setw(2) << std::setfill('0') << converted.tm_sec << " "; } void client_thread(const transport::AcceptedClient *accepted_client, int directory_fd, const Mime &mime) { + LogThreadId _log_thread_id; + assert(accepted_client); std::unique_ptr accepted_client_deleter{accepted_client}; @@ -194,6 +212,8 @@ void client_thread(const transport::AcceptedClient *ac bool server_loop(int server_socket, NotNullserver_ctx, int directory_fd, const Mime &mime) { + LogThreadId _log_thread_id; + error::g_log << "🚀 Vostok server listening..." << std::endl; for (; ; ) {