From 7c8a840aeec87bea1229392b1c01ff14ddbe3daa Mon Sep 17 00:00:00 2001 From: heck Date: Tue, 21 Apr 2020 00:06:23 +0200 Subject: [PATCH] pEpLog() / pEpErr() - enable automatic flushing on std::cout and std::cerr --- utils.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils.hh b/utils.hh index f03b500..cc253ed 100644 --- a/utils.hh +++ b/utils.hh @@ -37,6 +37,6 @@ inline std::string timestamp_usec() { #ifdef NDEBUG #define pEpLog(msg) do{}while(0) #else -#define pEpLog(msg) do{ std::cout << timestamp_usec() << " Thread:" << std::this_thread::get_id() << ' ' <<__FILE__ << "::" << __FUNCTION__ << " - " << msg << '\n';} while(0) +#define pEpLog(msg) do{ std::cout << std::unitbuf; std::cout << timestamp_usec() << " Thread:" << std::this_thread::get_id() << ' ' <<__FILE__ << "::" << __FUNCTION__ << " - " << msg << std::endl;} while(0) #endif -#define pEpErr(msg) do{ std::cout << timestamp_usec() << " Thread:" << std::this_thread::get_id() << ' ' <<__FILE__ << "::" << __FUNCTION__ << " - " << msg << '\n';} while(0) +#define pEpErr(msg) do{ std::cerr << std::unitbuf; std::cerr << timestamp_usec() << " Thread:" << std::this_thread::get_id() << ' ' <<__FILE__ << "::" << __FUNCTION__ << " - " << msg << std::endl;} while(0)