[libcalamares] Make running commands less chatty

If there's no output, don't mention it; don't mention failure modes
if the command was successful.
This commit is contained in:
Adriaan de Groot 2021-01-05 23:58:52 +01:00
parent c963d8905f
commit 132ff59d9c

View File

@ -201,12 +201,29 @@ System::runCommand( System::RunLocation location,
}
auto r = process.exitCode();
cDebug() << Logger::SubEntry << "Finished. Exit code:" << r;
bool showDebug = ( !Calamares::Settings::instance() ) || ( Calamares::Settings::instance()->debugMode() );
if ( ( r != 0 ) || showDebug )
if ( r == 0 )
{
cDebug() << Logger::SubEntry << "Target cmd:" << RedactedList( args ) << "output:\n"
<< Logger::NoQuote {} << output;
if ( showDebug && !output.isEmpty() )
{
cDebug() << Logger::SubEntry << "Finished. Exit code:" << r << "output:\n" << Logger::NoQuote {} << output;
}
else
{
cDebug() << Logger::SubEntry << "Finished. Exit code:" << r;
}
}
else // if ( r != 0 )
{
if ( !output.isEmpty() )
{
cDebug() << Logger::SubEntry << "Target cmd:" << RedactedList( args ) << "Exit code:" << r << "output:\n"
<< Logger::NoQuote {} << output;
}
else
{
cDebug() << Logger::SubEntry << "Target cmd:" << RedactedList( args ) << "Exit code:" << r << "(no output)";
}
}
return ProcessResult( r, output );
}