Writes the summarised repeated messages at the end of the log. Replaces the placeholders in unformatted messages '%...' with # using a regex.
| 187 | /// Writes the summarised repeated messages at the end of the log. |
| 188 | /// Replaces the placeholders in unformatted messages '%...' with # using a regex. |
| 189 | void flush_repeated_logs() { |
| 190 | bool printedHeader = false; |
| 191 | |
| 192 | for (const auto& [msg, data] : ext_log_entrys) { |
| 193 | if (data.count > data.rep_times) { |
| 194 | std::string repeated_msg = msg + " (repeated times: " + std::to_string(data.count) + ")"; |
| 195 | // replace all placeholder '%...' with '#' |
| 196 | if (repeated_msg.find('%') != std::string::npos) { |
| 197 | std::regex fmt_regex(R"(%([-+0 #]*)?(\d+|\*)?(\.\d+)?(hh|h|ll|l|j|z|t|L)?([diuoxXfFeEgGaAcspn%]))"); |
| 198 | repeated_msg = std::regex_replace(repeated_msg, fmt_regex, "#"); // Replaces every placeholder with # |
| 199 | } |
| 200 | if (!repeated_msg.empty() && repeated_msg != "#") { |
| 201 | if (!printedHeader) { |
| 202 | // Output heading once |
| 203 | (*message_handler)(LAS_INFO, "Summary of repeated logs:", message_user_data); |
| 204 | printedHeader = true; |
| 205 | } |
| 206 | (*message_handler)(data.type, repeated_msg.c_str(), message_user_data); |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | ext_log_entrys.clear(); |
| 211 | } |
| 212 | |
| 213 | void LASLIB_DLL set_message_log_level(LAS_MESSAGE_TYPE loglevel) { |
| 214 | if (las_message_level != loglevel) { |
no test coverage detected