From 38e5dbd866cbc1c7bb9fc51e91a3020f5b8578d7 Mon Sep 17 00:00:00 2001 From: gabime Date: Thu, 18 Jul 2019 00:55:24 +0300 Subject: [PATCH] Fix win-color sink redirection to file --- include/spdlog/sinks/wincolor_sink-inl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/spdlog/sinks/wincolor_sink-inl.h b/include/spdlog/sinks/wincolor_sink-inl.h index e8b9192e..949db310 100644 --- a/include/spdlog/sinks/wincolor_sink-inl.h +++ b/include/spdlog/sinks/wincolor_sink-inl.h @@ -149,12 +149,12 @@ void SPDLOG_INLINE wincolor_sink::write_to_file_(const fmt::memory DWORD total_written = 0; do { - DWORD bytes_written = 0; - bool ok = WriteFile(out_handle_, formatted.data(), size, &bytes_written, nullptr) != 0; + DWORD bytes_written = 0; + bool ok = WriteFile(out_handle_, formatted.data()+total_written, size-total_written, &bytes_written, nullptr) != 0; if (!ok || bytes_written == 0) { throw spdlog_ex("wincolor_sink: write_to_file_ failed. GetLastError(): " + std::to_string(::GetLastError())); - } + } total_written += bytes_written; } while (total_written < size); }