| 3399 | "ERROR_MESSAGE" }; |
| 3400 | |
| 3401 | void cmCTest::Log(LogType logType, std::string msg, bool suppress) |
| 3402 | { |
| 3403 | if (msg.empty()) { |
| 3404 | return; |
| 3405 | } |
| 3406 | if (suppress && logType != cmCTest::ERROR_MESSAGE) { |
| 3407 | return; |
| 3408 | } |
| 3409 | if (logType == cmCTest::HANDLER_PROGRESS_OUTPUT && |
| 3410 | (this->Impl->Debug || this->Impl->ExtraVerbose)) { |
| 3411 | return; |
| 3412 | } |
| 3413 | if (this->Impl->OutputLogFile) { |
| 3414 | bool display = true; |
| 3415 | if (logType == cmCTest::DEBUG && !this->Impl->Debug) { |
| 3416 | display = false; |
| 3417 | } |
| 3418 | if (logType == cmCTest::HANDLER_VERBOSE_OUTPUT && !this->Impl->Debug && |
| 3419 | !this->Impl->ExtraVerbose) { |
| 3420 | display = false; |
| 3421 | } |
| 3422 | if (display) { |
| 3423 | if (this->Impl->OutputLogFileLastTag && |
| 3424 | logType != *this->Impl->OutputLogFileLastTag) { |
| 3425 | *this->Impl->OutputLogFile << "[" << cmCTestStringLogType[logType] |
| 3426 | << "] " << std::endl; |
| 3427 | } |
| 3428 | *this->Impl->OutputLogFile << msg << std::flush; |
| 3429 | if (this->Impl->OutputLogFileLastTag && |
| 3430 | logType != *this->Impl->OutputLogFileLastTag) { |
| 3431 | *this->Impl->OutputLogFile << std::endl; |
| 3432 | this->Impl->OutputLogFileLastTag = logType; |
| 3433 | } |
| 3434 | } |
| 3435 | } |
| 3436 | if (!this->Impl->Quiet) { |
| 3437 | if (logType == HANDLER_TEST_PROGRESS_OUTPUT) { |
| 3438 | if (this->Impl->TestProgressOutput) { |
| 3439 | if (this->Impl->FlushTestProgressLine) { |
| 3440 | printf("\r"); |
| 3441 | this->Impl->FlushTestProgressLine = false; |
| 3442 | std::cout.flush(); |
| 3443 | } |
| 3444 | |
| 3445 | if (msg.find('\n') != std::string::npos) { |
| 3446 | this->Impl->FlushTestProgressLine = true; |
| 3447 | msg.erase(std::remove(msg.begin(), msg.end(), '\n'), msg.end()); |
| 3448 | } |
| 3449 | |
| 3450 | std::cout << msg; |
| 3451 | #ifndef _WIN32 |
| 3452 | printf("\x1B[K"); // move caret to end |
| 3453 | #endif |
| 3454 | std::cout.flush(); |
| 3455 | return; |
| 3456 | } |
| 3457 | logType = HANDLER_OUTPUT; |
| 3458 | } |
no test coverage detected