mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 08:40:19 +00:00
logging: check if output is a terminal only once
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
@@ -170,6 +170,7 @@ private:
|
||||
std::atomic<bool> 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<std::mutex> 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);
|
||||
|
||||
Reference in New Issue
Block a user