[libcalamares] Simplify logging-manipulators

Writing `Logger::NoQuote{}`` has annoyed me for a while, so
switch it to a constant, like SubEntry, so it looks more
like a regular manipulator object.
This commit is contained in:
Adriaan de Groot 2021-01-26 00:13:10 +01:00
parent 9a4c599e22
commit f0fd47eeb3
5 changed files with 17 additions and 13 deletions

View File

@ -188,7 +188,7 @@ System::runCommand( System::RunLocation location,
: -1 ) )
{
cWarning() << "Process" << args.first() << "timed out after" << timeoutSec.count() << "s. Output so far:\n"
<< Logger::NoQuote {} << process.readAllStandardOutput();
<< Logger::NoQuote << process.readAllStandardOutput();
return ProcessResult::Code::TimedOut;
}
@ -196,7 +196,7 @@ System::runCommand( System::RunLocation location,
if ( process.exitStatus() == QProcess::CrashExit )
{
cWarning() << "Process" << args.first() << "crashed. Output so far:\n" << Logger::NoQuote {} << output;
cWarning() << "Process" << args.first() << "crashed. Output so far:\n" << Logger::NoQuote << output;
return ProcessResult::Code::Crashed;
}
@ -206,7 +206,7 @@ System::runCommand( System::RunLocation location,
{
if ( showDebug && !output.isEmpty() )
{
cDebug() << Logger::SubEntry << "Finished. Exit code:" << r << "output:\n" << Logger::NoQuote {} << output;
cDebug() << Logger::SubEntry << "Finished. Exit code:" << r << "output:\n" << Logger::NoQuote << output;
}
else
{
@ -218,7 +218,7 @@ System::runCommand( System::RunLocation location,
if ( !output.isEmpty() )
{
cDebug() << Logger::SubEntry << "Target cmd:" << RedactedList( args ) << "Exit code:" << r << "output:\n"
<< Logger::NoQuote {} << output;
<< Logger::NoQuote << output;
}
else
{

View File

@ -207,6 +207,8 @@ constexpr FuncSuppressor::FuncSuppressor( const char s[] )
const constexpr FuncSuppressor Continuation( s_Continuation );
const constexpr FuncSuppressor SubEntry( s_SubEntry );
const constexpr NoQuote_t NoQuote {};
const constexpr Quote_t Quote {};
QString
toString( const QVariant& v )

View File

@ -25,15 +25,17 @@ struct FuncSuppressor
const char* m_s;
};
struct NoQuote
struct NoQuote_t
{
};
struct Quote
struct Quote_t
{
};
DLLEXPORT extern const FuncSuppressor Continuation;
DLLEXPORT extern const FuncSuppressor SubEntry;
DLLEXPORT extern const NoQuote_t NoQuote;
DLLEXPORT extern const Quote_t Quote;
enum
{
@ -74,13 +76,13 @@ operator<<( QDebug& s, const FuncSuppressor& f )
}
inline QDebug&
operator<<( QDebug& s, const NoQuote& )
operator<<( QDebug& s, const NoQuote_t& )
{
return s.noquote().nospace();
}
inline QDebug&
operator<<( QDebug& s, const Quote& )
operator<<( QDebug& s, const Quote_t& )
{
return s.quote().space();
}
@ -254,7 +256,7 @@ operator<<( QDebug& s, const DebugMap& t )
inline QDebug&
operator<<( QDebug& s, const Pointer& p )
{
s << NoQuote {} << '@' << p.ptr << Quote {};
s << NoQuote << '@' << p.ptr << Quote;
return s;
}
} // namespace Logger

View File

@ -35,7 +35,7 @@
[[noreturn]] static void
bail( const QString& descriptorPath, const QString& message )
{
cError() << "FATAL in" << descriptorPath << Logger::Continuation << Logger::NoQuote {} << message;
cError() << "FATAL in" << descriptorPath << Logger::Continuation << Logger::NoQuote << message;
::exit( EXIT_FAILURE );
}

View File

@ -142,9 +142,9 @@ ViewManager::onInstallationFailed( const QString& message, const QString& detail
{
bool shouldOfferWebPaste = false; // TODO: config var
cError() << "Installation failed:";
cDebug() << "- message:" << message;
cDebug() << "- details:" << details;
cError() << "Installation failed:" << message;
cDebug() << Logger::SubEntry << "- message:" << message;
cDebug() << Logger::SubEntry << "- details:" << Logger::NoQuote << details;
QString heading
= Calamares::Settings::instance()->isSetupMode() ? tr( "Setup Failed" ) : tr( "Installation Failed" );