| 336 | } |
| 337 | |
| 338 | void ccConsole::logMessage(const QString& message, int level) |
| 339 | { |
| 340 | //skip messages below the current 'verbosity' level |
| 341 | if ((level & 7) < ccLog::VerbosityLevel()) |
| 342 | { |
| 343 | return; |
| 344 | } |
| 345 | |
| 346 | QString formatedMessage = QStringLiteral("[") + QTime::currentTime().toString() + QStringLiteral("] ") + message; |
| 347 | if (s_redirectToStdOut) |
| 348 | { |
| 349 | printf("%s\n", qPrintable(formatedMessage)); |
| 350 | } |
| 351 | if (m_textDisplay || m_logStream) |
| 352 | { |
| 353 | m_mutex.lock(); |
| 354 | m_queue.push_back(ConsoleItemType(formatedMessage, level)); |
| 355 | m_mutex.unlock(); |
| 356 | } |
| 357 | #ifdef QT_DEBUG |
| 358 | else if (!s_redirectToStdOut) |
| 359 | { |
| 360 | //Error |
| 361 | if (level & LOG_ERROR) |
| 362 | { |
| 363 | if (level & DEBUG_FLAG) |
| 364 | printf("ERR-DBG: "); |
| 365 | else |
| 366 | printf("ERR: "); |
| 367 | } |
| 368 | //Warning |
| 369 | else if (level & LOG_WARNING) |
| 370 | { |
| 371 | if (level & DEBUG_FLAG) |
| 372 | printf("WARN-DBG: "); |
| 373 | else |
| 374 | printf("WARN: "); |
| 375 | } |
| 376 | //Standard |
| 377 | else |
| 378 | { |
| 379 | if (level & DEBUG_FLAG) |
| 380 | printf("MSG-DBG: "); |
| 381 | else |
| 382 | printf("MSG: "); |
| 383 | } |
| 384 | printf(" %s\n", qPrintable(formatedMessage)); |
| 385 | } |
| 386 | #endif |
| 387 | |
| 388 | //we display the error messages in a popup dialog |
| 389 | if ( (level & LOG_ERROR) |
| 390 | && qApp |
| 391 | && m_parentWidget |
| 392 | && QThread::currentThread() == qApp->thread() |
| 393 | ) |
| 394 | { |
| 395 | QMessageBox::warning(m_parentWidget, "Error", message); |
no test coverage detected