Skip to content

Commit 42cb4d3

Browse files
authored
Merge pull request #996 from lplewa/log-fixes
"add missing new lines in logger error messages" and "Fix infinite loop in logger."
2 parents 63aaf07 + 4e56410 commit 42cb4d3

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

source/common/logger/ur_sinks.hpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,17 @@ class Sink {
6767
if (*(++fmt) == '{') {
6868
buffer << *fmt++;
6969
} else {
70-
std::cerr
71-
<< error_prefix
72-
<< "No arguments provided and braces not escaped!";
70+
std::cerr << error_prefix
71+
<< "No arguments provided and braces not escaped!"
72+
<< std::endl;
7373
}
7474
} else if (*fmt == '}') {
7575
if (*(++fmt) == '}') {
7676
buffer << *fmt++;
7777
} else {
7878
std::cerr << error_prefix
79-
<< "Closing curly brace not escaped!";
79+
<< "Closing curly brace not escaped!"
80+
<< std::endl;
8081
}
8182
}
8283
}
@@ -97,7 +98,7 @@ class Sink {
9798
buffer << *fmt++;
9899
} else if (*fmt != '}') {
99100
std::cerr << error_prefix
100-
<< "Only empty braces are allowed!";
101+
<< "Only empty braces are allowed!" << std::endl;
101102
} else {
102103
buffer << arg;
103104
arg_printed = true;
@@ -107,9 +108,17 @@ class Sink {
107108
buffer << *fmt++;
108109
} else {
109110
std::cerr << error_prefix
110-
<< "Closing curly brace not escaped!";
111+
<< "Closing curly brace not escaped!"
112+
<< std::endl;
111113
}
112114
}
115+
116+
if (*fmt == '\0') {
117+
std::cerr << error_prefix << "Too many arguments!" << std::endl;
118+
// ignore all left arguments and finalize message
119+
format(buffer, fmt);
120+
return;
121+
}
113122
}
114123

115124
format(buffer, ++fmt, std::forward<Args &&>(args)...);

0 commit comments

Comments
 (0)