Skip to content

Commit

Permalink
Flush the logs if --Debug=true is set
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Jul 18, 2019
1 parent 1097881 commit 65e0457
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
23 changes: 13 additions & 10 deletions OMEdit/OMEdit/OMEditGUI/OMC/OMCProxy.cpp
Expand Up @@ -384,17 +384,16 @@ void OMCProxy::logCommand(QString command, QTime *commandTime, bool saveToHistor
*/
void OMCProxy::logResponse(QString command, QString response, QTime *responseTime)
{
double elapsed = (double)responseTime->elapsed() / 1000.0;
QString firstLine("");
for (int i = 0; i < command.length(); i++)
if (command[i] != '\n')
{
firstLine.append(command[i]);
}
else
break;

if (isLoggingEnabled()) {
double elapsed = (double)responseTime->elapsed() / 1000.0;
QString firstLine("");
for (int i = 0; i < command.length(); i++) {
if (command[i] != '\n') {
firstLine.append(command[i]);
} else {
break;
}
}
// insert the response to the logger window.
QFont font(Helper::monospacedFontInfo.family(), Helper::monospacedFontInfo.pointSize() - 2, QFont::Normal, false);
QTextCharFormat format;
Expand All @@ -406,6 +405,10 @@ void OMCProxy::logResponse(QString command, QString response, QTime *responseTim
fputs(QString("%1 %2\n").arg(response).arg(responseTime->currentTime().toString("hh:mm:ss:zzz")).toUtf8().constData(), mpCommunicationLogFile);
fputs(QString("#s#; %1; %2; \'%3\'\n\n").arg(QString::number(elapsed, 'f', 6)).arg(QString::number(mTotalOMCCallsTime, 'f', 6)).arg(firstLine).toUtf8().constData(), mpCommunicationLogFile);
}
// flush the logs if --Debug=true
if (MainWindow::instance()->isDebug()) {
fflush(NULL);
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions OMEdit/OMEdit/OMEditGUI/OMS/OMSProxy.cpp
Expand Up @@ -182,6 +182,11 @@ void OMSProxy::logResponse(QString command, oms_status_enu_t status, QTime *resp
fputs(QString("#s#; %1; %2; \'%3\'\n\n").arg(QString::number(elapsed, 'f', 6)).arg(QString::number(mTotalOMSCallsTime, 'f', 6)).arg(firstLine).toUtf8().constData(), mpCommunicationLogFile);
}

// flush the logs if --Debug=true
if (MainWindow::instance()->isDebug()) {
fflush(NULL);
}

MainWindow::instance()->printStandardOutAndErrorFilesMessages();
}

Expand Down

0 comments on commit 65e0457

Please sign in to comment.