MCPcopy Create free account
hub / github.com/LASzip/LASzip / flush_repeated_logs

Function flush_repeated_logs

src/lasmessage.cpp:190–212  ·  view source on GitHub ↗

Writes the summarised repeated messages at the end of the log. Replaces the placeholders in unformatted messages '%...' with # using a regex.

Source from the content-addressed store, hash-verified

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

Callers 1

LASLIB_DLL byebyeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected