logic: write output of Python indexer processes to log file

This commit is contained in:
mlangkabel
2019-05-27 14:05:02 +02:00
parent f087d7e5ea
commit 581b1894f2
3 changed files with 76 additions and 40 deletions
@@ -219,37 +219,32 @@ void TaskExecuteCustomCommands::runIndexerCommand(std::shared_ptr<IndexerCommand
m_storage->beforeErrorRecording();
std::wstring processOutput;
std::wstring errorMessage;
const int result = utility::executeProcessAndGetExitCode(command, {}, m_projectDirectory, -1, &processOutput, &errorMessage);
const int result = utility::executeProcessAndGetExitCode(command, {}, m_projectDirectory, -1, true, &errorMessage);
m_storage->afterErrorRecording();
if (errorMessage.size() > 0 || processOutput.size() > 3 || result != 0)
if (result == 0 && errorMessage.empty())
{
if (result == 0 && errorMessage.empty())
std::wstring message = L"Process returned successfully.\n";
LOG_INFO(message);
}
else
{
std::wstring statusText = L"command \"" + indexerCommand->getCustomCommand() + L"\" returned";
if (result != 0)
{
std::wstring message = L"Process returned successfully";
if (processOutput.empty())
{
message += L".";
}
else
{
message += L" with message \"" + processOutput + L"\".";
}
message += L"\n";
LOG_INFO(message);
statusText += L" code \"" + std::to_wstring(result) + L"\"";
}
else
if (!errorMessage.empty())
{
LOG_ERROR_STREAM(<< "process returned \"" << result << "\" with message:\n" << utility::encodeToUtf8(processOutput));
MessageShowStatus().dispatch();
MessageStatus(
L"command \"" + indexerCommand->getCustomCommand() + L"\" returned code \"" + std::to_wstring(result) + L"\"" +
L" with message \"" + errorMessage + L"\"" +
L" and output \"" + processOutput + L"\".", true, false, true).dispatch();
statusText += L" with message \"" + errorMessage + L"\"";
}
statusText += L".";
LOG_ERROR(statusText);
MessageShowStatus().dispatch();
MessageStatus(statusText, true, false, true).dispatch();
}
indexedSourceFileCount++;