mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 08:25:43 +08:00
Fix stdout_sink_base::log's behavior inconsistency (#2646)
* Fix stdout_sink_base::log's behavior inconsistency It will flush every time when it if not defined _WIN32, but not in Windows family. We viewed the commit #48d4ed9 for fixing issue #1675 . It seems missing this flushing operation in mistake. * Use fflush at all operating system * Remove redundant fflush from stdout_sink_base --------- Co-authored-by: scc <scc@teamt5.org>
This commit is contained in:
parent
040874224b
commit
42d1f40a18
@ -60,7 +60,6 @@ SPDLOG_INLINE void stdout_sink_base<ConsoleMutex>::log(const details::log_msg &m
|
|||||||
std::lock_guard<mutex_t> lock(mutex_);
|
std::lock_guard<mutex_t> lock(mutex_);
|
||||||
memory_buf_t formatted;
|
memory_buf_t formatted;
|
||||||
formatter_->format(msg, formatted);
|
formatter_->format(msg, formatted);
|
||||||
::fflush(file_); // flush in case there is something in this file_ already
|
|
||||||
auto size = static_cast<DWORD>(formatted.size());
|
auto size = static_cast<DWORD>(formatted.size());
|
||||||
DWORD bytes_written = 0;
|
DWORD bytes_written = 0;
|
||||||
bool ok = ::WriteFile(handle_, formatted.data(), size, &bytes_written, nullptr) != 0;
|
bool ok = ::WriteFile(handle_, formatted.data(), size, &bytes_written, nullptr) != 0;
|
||||||
@ -73,8 +72,8 @@ SPDLOG_INLINE void stdout_sink_base<ConsoleMutex>::log(const details::log_msg &m
|
|||||||
memory_buf_t formatted;
|
memory_buf_t formatted;
|
||||||
formatter_->format(msg, formatted);
|
formatter_->format(msg, formatted);
|
||||||
::fwrite(formatted.data(), sizeof(char), formatted.size(), file_);
|
::fwrite(formatted.data(), sizeof(char), formatted.size(), file_);
|
||||||
::fflush(file_); // flush every line to terminal
|
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
::fflush(file_); // flush every line to terminal
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ConsoleMutex>
|
template<typename ConsoleMutex>
|
||||||
|
Loading…
Reference in New Issue
Block a user