From 132ff59d9c8b20147d3e16112c70998b59b05c69 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 5 Jan 2021 23:58:52 +0100 Subject: [PATCH] [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. --- .../utils/CalamaresUtilsSystem.cpp | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/libcalamares/utils/CalamaresUtilsSystem.cpp b/src/libcalamares/utils/CalamaresUtilsSystem.cpp index dad6e5b12..841d52969 100644 --- a/src/libcalamares/utils/CalamaresUtilsSystem.cpp +++ b/src/libcalamares/utils/CalamaresUtilsSystem.cpp @@ -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 ); }