diff --git a/src/debug.cpp b/src/debug.cpp index 31a2cb6f6..3b035b343 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -382,4 +382,5 @@ thread_local std::string Log_output::buffer(initial_buf_size, '\0'); Log_output::Log_output(){ last_msg.reserve(initial_buf_size); + interactive = rang::rang_implementation::isTerminal(std::cout.rdbuf()); } diff --git a/src/debug.h b/src/debug.h index 9a9d62d11..894090a54 100644 --- a/src/debug.h +++ b/src/debug.h @@ -170,6 +170,7 @@ private: std::atomic skip_repeated; log_timestamp_mode show_timestamps; + bool interactive = false; /* Since writing to stdout uses locks internally anyway (C11 standard * 7.21.2 sections 7&8), using a mutex here does not cause any significant @@ -222,7 +223,7 @@ inline void Log_output::submit(){ const char *start_newline = ""; std::lock_guard lock(mut); - if (skip_repeated && rang::rang_implementation::isTerminal(std::clog.rdbuf())) { + if (skip_repeated && interactive) { if (buffer == last_msg) { last_msg_repeats++; printf(" Last message repeated %d times\r", last_msg_repeats);