commit 4613bf1c4fa827736cdd51b4b653be8381c7d9d7 from: Aleksey Ryndin date: Mon Apr 15 14:59:18 2024 UTC Add time labels (debug) commit - 75dce1ffacfea704c2d8568b9cdf874827d72ff9 commit + 4613bf1c4fa827736cdd51b4b653be8381c7d9d7 blob - 15ab6a18586dacba22d08d61f062ca0c066aa595 blob + b31bdb54934d0291bfc573eb0c4c321bb17e3d91 --- vostok/vostok.cc +++ vostok/vostok.cc @@ -15,7 +15,10 @@ #include #include +#include +#include + namespace vostok { namespace @@ -53,6 +56,14 @@ bool send_response(NotNull ctx, gemini:: return true; } + +void put_time_prefix() +{ + const std::time_t t{std::time(nullptr)}; + struct tm converted{}; + gmtime_r(&t, &converted); + error::g_log << converted.tm_hour << ":" << converted.tm_min << ":" << converted.tm_sec << " "; +} void client_thread(const transport::AcceptedClient *accepted_client, int directory_fd, const Mime &mime) @@ -168,6 +179,8 @@ void client_thread(const transport::AcceptedClient *ac if (readed < buffer.size()) break; } + + put_time_prefix(); error::g_log << "20 " << meta_string << " \"" << path << "\"" << std::endl; } @@ -188,6 +201,7 @@ bool server_loop(int server_socket, NotNullis_accepted()) { + put_time_prefix(); try { std::thread{client_thread, accepted_client.get(), directory_fd, mime}.detach();