MCPcopy Create free account
hub / github.com/EasyRPG/Player / WriteLog

Function WriteLog

src/output.cpp:138–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138static 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
169static void HandleErrorOutput(const std::string& err) {
170 // Drawing directly on the screen because message_overlay is not visible

Callers 4

ErrorStrMethod · 0.85
WarningStrMethod · 0.85
InfoStrMethod · 0.85
DebugStrMethod · 0.85

Calls 2

AddMessageMethod · 0.80
ColorClass · 0.70

Tested by

no test coverage detected