MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / _append

Method _append

LogManager.cpp:191–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191void LogManager::_append(const char* filename, int line, unsigned int level, const char* fmt, va_list va)
192{
193 /*-------------------------------------------------*\
194 | If a critical message occurs, enable source |
195 | printing and set loglevel and verbosity to highest|
196 \*-------------------------------------------------*/
197 if(level == LL_FATAL)
198 {
199 print_source = true;
200 loglevel = LL_DEBUG;
201 verbosity = LL_DEBUG;
202 }
203
204 /*-------------------------------------------------*\
205 | Create a new message |
206 \*-------------------------------------------------*/
207 PLogMessage mes = std::make_shared<LogMessage>();
208
209 /*-------------------------------------------------*\
210 | Resize the buffer, then fill in the message text |
211 \*-------------------------------------------------*/
212 va_list va2;
213 va_copy(va2, va);
214 int len = vsnprintf(nullptr, 0, fmt, va);
215 mes->buffer.resize(len);
216 vsnprintf(&(mes->buffer[0]), len + 1, fmt, va2);
217 va_end(va2);
218
219 /*-------------------------------------------------*\
220 | Fill in message information |
221 \*-------------------------------------------------*/
222 mes->level = level;
223 mes->filename = filename;
224 mes->line = line;
225 mes->counted_second = std::chrono::steady_clock::now() - base_clock;
226
227 /*-------------------------------------------------*\
228 | If this is a dialog message, call the dialog show |
229 | callback |
230 \*-------------------------------------------------*/
231 if(level == LL_DIALOG)
232 {
233 for(size_t idx = 0; idx < dialog_show_callbacks.size(); idx++)
234 {
235 dialog_show_callbacks[idx](dialog_show_callback_args[idx], mes);
236 }
237 }
238
239 /*-------------------------------------------------*\
240 | If the message is within the current verbosity, |
241 | print it on the screen |
242 | TODO: Put the timestamp here |
243 \*-------------------------------------------------*/
244 if(level <= verbosity || level == LL_DIALOG)
245 {
246 std::cout << mes->buffer;
247 if(print_source)
248 {

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected