util/posix_logger.h [42:66]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - constexpr const int kMaxThreadIdSize = 32; std::ostringstream thread_stream; thread_stream << std::this_thread::get_id(); std::string thread_id = thread_stream.str(); if (thread_id.size() > kMaxThreadIdSize) { thread_id.resize(kMaxThreadIdSize); } // We first attempt to print into a stack-allocated buffer. If this attempt // fails, we make a second attempt with a dynamically allocated buffer. constexpr const int kStackBufferSize = 512; char stack_buffer[kStackBufferSize]; static_assert(sizeof(stack_buffer) == static_cast(kStackBufferSize), "sizeof(char) is expected to be 1 in C++"); int dynamic_buffer_size = 0; // Computed in the first iteration. for (int iteration = 0; iteration < 2; ++iteration) { const int buffer_size = (iteration == 0) ? kStackBufferSize : dynamic_buffer_size; char* const buffer = (iteration == 0) ? stack_buffer : new char[dynamic_buffer_size]; // Print the header into the buffer. int buffer_offset = std::snprintf( buffer, buffer_size, "%04d/%02d/%02d-%02d:%02d:%02d.%06d %s ", - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - util/windows_logger.h [36:60]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - constexpr const int kMaxThreadIdSize = 32; std::ostringstream thread_stream; thread_stream << std::this_thread::get_id(); std::string thread_id = thread_stream.str(); if (thread_id.size() > kMaxThreadIdSize) { thread_id.resize(kMaxThreadIdSize); } // We first attempt to print into a stack-allocated buffer. If this attempt // fails, we make a second attempt with a dynamically allocated buffer. constexpr const int kStackBufferSize = 512; char stack_buffer[kStackBufferSize]; static_assert(sizeof(stack_buffer) == static_cast(kStackBufferSize), "sizeof(char) is expected to be 1 in C++"); int dynamic_buffer_size = 0; // Computed in the first iteration. for (int iteration = 0; iteration < 2; ++iteration) { const int buffer_size = (iteration == 0) ? kStackBufferSize : dynamic_buffer_size; char* const buffer = (iteration == 0) ? stack_buffer : new char[dynamic_buffer_size]; // Print the header into the buffer. int buffer_offset = std::snprintf( buffer, buffer_size, "%04d/%02d/%02d-%02d:%02d:%02d.%06d %s ", - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -