| 136 | } |
| 137 | |
| 138 | static void WriteLog(LogLevel lvl, std::string const& msg, Color const& c = Color()) { |
| 139 | // skip writing log file |
| 140 | #ifndef EMSCRIPTEN |
| 141 | std::string prefix = Output::LogLevelToString(lvl) + ": "; |
| 142 | |
| 143 | // Every new message is written once to the file. |
| 144 | // When it is repeated increment a counter until a different message appears, |
| 145 | // then write the buffered message with the counter. |
| 146 | if (msg == last_message.msg) { |
| 147 | last_message.repeat++; |
| 148 | } else { |
| 149 | if (last_message.repeat > 0) { |
| 150 | output_time() << Output::LogLevelToString(last_message.lvl) << ": " << last_message.msg << " [" << last_message.repeat + 1 << "x]" << std::endl; |
| 151 | } |
| 152 | output_time() << prefix << msg << '\n'; |
| 153 | |
| 154 | last_message.repeat = 0; |
| 155 | last_message.msg = msg; |
| 156 | last_message.lvl = lvl; |
| 157 | } |
| 158 | #endif |
| 159 | |
| 160 | // output to custom logger or terminal |
| 161 | log_cb(lvl, msg, log_cb_udata); |
| 162 | |
| 163 | // output to overlay |
| 164 | if (lvl != LogLevel::Debug && lvl != LogLevel::Error) { |
| 165 | Graphics::GetMessageOverlay().AddMessage(msg, c); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | static void HandleErrorOutput(const std::string& err) { |
| 170 | // Drawing directly on the screen because message_overlay is not visible |
no test coverage detected