From cb3799c3fa3c9e77df1670f269d79ee759a4017e Mon Sep 17 00:00:00 2001 From: Rao Meng Date: Tue, 6 Jul 2021 08:08:26 +0800 Subject: [PATCH] Improve flushing for un-managed fp such as stdout; upgrade fmt to 8.0.1 --- fmt | 2 +- fmtlog-inl.h | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/fmt b/fmt index 002bb75..d141cdb 160000 --- a/fmt +++ b/fmt @@ -1 +1 @@ -Subproject commit 002bb759ffc2ba03c7167d22cb58291b1b933af4 +Subproject commit d141cdbeb0fb422a3fb7173b285fd38e0d1772dc diff --git a/fmtlog-inl.h b/fmtlog-inl.h index b698561..0d51b66 100644 --- a/fmtlog-inl.h +++ b/fmtlog-inl.h @@ -293,7 +293,10 @@ class fmtlogDetailT } void flushLogFile() { - if (outputFp) fwrite(membuf.data(), 1, membuf.size(), outputFp); + if (outputFp) { + fwrite(membuf.data(), 1, membuf.size(), outputFp); + if (!manageFp) fflush(outputFp); + } membuf.clear(); nextFlushTime = (std::numeric_limits::max)(); }