| 96 | } |
| 97 | |
| 98 | void LASMessage(LAS_MESSAGE_TYPE type, LAS_FORMAT_STRING(const char*) fmt, ...) { |
| 99 | assert(type <= LAS_FATAL_ERROR); // message type must be less than or equal to LAS_FATAL_ERROR (LAS_QUIET must not be used in LASMessage calls) |
| 100 | |
| 101 | if (type >= 0 && type <= LAS_QUIET) lasmessage_cnt[type]++; |
| 102 | |
| 103 | if (type < las_message_level) return; |
| 104 | |
| 105 | va_list args; |
| 106 | va_start(args, fmt); |
| 107 | char buffer[LAS_MAX_MESSAGE_LENGTH]; |
| 108 | buildMessage(buffer, type, fmt, args); |
| 109 | va_end(args); |
| 110 | |
| 111 | if (current_msg != fmt) { |
| 112 | if (rep_log_msg > max_rep_log_msg) { |
| 113 | std::string rep_msg = "(log message repeated " + std::to_string(rep_log_msg) + " times)"; |
| 114 | (*message_handler)(LAS_INFO, rep_msg.c_str(), message_user_data); |
| 115 | } |
| 116 | // message template (unformatted message) |
| 117 | current_msg = fmt; |
| 118 | rep_log_msg = 1; |
| 119 | } else { |
| 120 | ++rep_log_msg; |
| 121 | } |
| 122 | |
| 123 | if (rep_log_msg <= max_rep_log_msg) { |
| 124 | (*message_handler)(type, buffer, message_user_data); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | /// Reduces repetitive log messages and summarises them. |
| 129 | /// On the one hand, both formatted and unformatted messages (arguments inserted and not) are collected. |
no test coverage detected