| 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 | lasmessage_cnt[type]++; |
| 102 | |
| 103 | if (type < las_message_level) return; |
| 104 | |
| 105 | bool clear_log_entry = false; |
| 106 | va_list args; |
| 107 | va_start(args, fmt); |
| 108 | char buffer[LAS_MAX_MESSAGE_LENGTH]; |
| 109 | buildMessage(buffer, type, fmt, args); |
| 110 | va_end(args); |
| 111 | |
| 112 | if (current_msg != fmt) { |
| 113 | if (rep_log_msg > max_rep_log_msg) { |
| 114 | std::string rep_msg = "(log message repeated " + std::to_string(rep_log_msg) + " times)"; |
| 115 | (*message_handler)(LAS_INFO, rep_msg.c_str(), message_user_data); |
| 116 | } |
| 117 | // message template (unformatted message) |
| 118 | current_msg = fmt; |
| 119 | rep_log_msg = 1; |
| 120 | } else { |
| 121 | ++rep_log_msg; |
| 122 | } |
| 123 | |
| 124 | if (rep_log_msg <= max_rep_log_msg) { |
| 125 | (*message_handler)(type, buffer, message_user_data); |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | /// Reduces repetitive log messages and summarises them. |
| 130 | /// On the one hand, both formatted and unformatted messages (arguments inserted and not) are collected. |
no test coverage detected