[libcalamares] Improve process logging

- Log output on crash
 - If debugging is on (-d) then also log output on success

FIXES #925
This commit is contained in:
Adriaan de Groot 2018-04-05 04:51:51 -04:00
parent 4d459f7fc0
commit b5c3fc8cf6

View File

@ -20,8 +20,9 @@
#include "CalamaresUtilsSystem.h" #include "CalamaresUtilsSystem.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "JobQueue.h"
#include "GlobalStorage.h" #include "GlobalStorage.h"
#include "JobQueue.h"
#include "Settings.h"
#include <QCoreApplication> #include <QCoreApplication>
#include <QDir> #include <QDir>
@ -173,7 +174,7 @@ System::runCommand(
if ( !process.waitForFinished( timeoutSec ? ( timeoutSec * 1000 ) : -1 ) ) if ( !process.waitForFinished( timeoutSec ? ( timeoutSec * 1000 ) : -1 ) )
{ {
cWarning() << "Timed out. output so far:\n" << cWarning() << "Timed out. Output so far:\n" <<
process.readAllStandardOutput(); process.readAllStandardOutput();
return -4; return -4;
} }
@ -182,13 +183,13 @@ System::runCommand(
if ( process.exitStatus() == QProcess::CrashExit ) if ( process.exitStatus() == QProcess::CrashExit )
{ {
cWarning() << "Process crashed"; cWarning() << "Process crashed. Output so far:\n" << output;
return -1; return -1;
} }
auto r = process.exitCode(); auto r = process.exitCode();
cDebug() << "Finished. Exit code:" << r; cDebug() << "Finished. Exit code:" << r;
if ( r != 0 ) if ( ( r != 0 ) || Calamares::Settings::instance()->debugMode() )
{ {
cDebug() << "Target cmd:" << args; cDebug() << "Target cmd:" << args;
cDebug().noquote() << "Target output:\n" << output; cDebug().noquote() << "Target output:\n" << output;