mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-24 06:32:06 +08:00
Simplify WriteFile() usage under windows
This commit is contained in:
parent
48d4ed9bc0
commit
cfd0ea197c
@ -151,17 +151,12 @@ void SPDLOG_INLINE wincolor_sink<ConsoleMutex>::write_to_file_(const memory_buf_
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD total_written = 0;
|
DWORD bytes_written = 0;
|
||||||
do
|
bool ok = ::WriteFile(out_handle_, formatted.data(), size, &bytes_written, nullptr) != 0;
|
||||||
|
if (!ok)
|
||||||
{
|
{
|
||||||
DWORD bytes_written = 0;
|
throw_spdlog_ex("wincolor_sink: write_to_file_ failed. GetLastError(): " + std::to_string(::GetLastError()));
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// wincolor_stdout_sink
|
// wincolor_stdout_sink
|
||||||
|
Loading…
Reference in New Issue
Block a user