[libcalamares] Simplify writing of logging continuations

- Instead of Continuation(), write just Continuation
 - All that futzing with overloads and tag-classes isn't needed
   since the whole point is to output some constant string. Leave
   cleverness for later, if it's needed.
This commit is contained in:
Adriaan de Groot 2019-04-15 07:57:25 -04:00
parent 4987dc31a1
commit d72e3b3c22
2 changed files with 7 additions and 59 deletions

View File

@ -189,36 +189,8 @@ CDebug::~CDebug()
{ {
} }
static const char continuation[] = "\n "; const char Continuation[] = "\n ";
static const char subentry[] = " .. "; const char SubEntry[] = " .. ";
QDebug&
operator<<( QDebug& s, Continuation )
{
s << continuation;
return s;
}
QDebug&
operator<<( QDebug& s, SubEntry )
{
s << subentry;
return s;
}
CDebug&
operator<<( CDebug&& s, Continuation )
{
s << continuation;
return s;
}
CDebug&
operator<<( CDebug&& s, SubEntry )
{
s << subentry;
return s;
}
QString toString( const QVariant& v ) QString toString( const QVariant& v )
{ {

View File

@ -27,25 +27,8 @@
namespace Logger namespace Logger
{ {
/** @brief tag-class used for continuing debug-output on the next line DLLEXPORT extern const char Continuation[];
* DLLEXPORT extern const char SubEntry[];
* A continuation starts a new debug-log line, without the timestamp and
* other leading information. Used when dumping tables and lists. Represented
* in the log by a newline and four spaces.
*/
struct Continuation
{
} ;
/** @brief tag-class used to indicate a log line is a sub-entry
*
* Sub-entries indicate additional information that isn't a continuation
* of the previous line, or sub-steps of something that has already been logged.
* Represented in the log as space dot dot space.
*/
struct SubEntry
{
} ;
enum enum
{ {
@ -113,13 +96,6 @@ namespace Logger
/** @brief Would the given @p level really be logged? */ /** @brief Would the given @p level really be logged? */
DLLEXPORT bool logLevelEnabled( unsigned int level ); DLLEXPORT bool logLevelEnabled( unsigned int level );
/// @brief Output a continuation
DLLEXPORT CDebug& operator <<( CDebug&& s, Continuation c );
DLLEXPORT QDebug& operator <<( QDebug& s, Continuation c );
/// @brief Output a subentry marker
DLLEXPORT CDebug& operator <<( CDebug&& s, SubEntry level );
DLLEXPORT QDebug& operator <<( QDebug& s, SubEntry level );
/** /**
* @brief Row-oriented formatted logging. * @brief Row-oriented formatted logging.
* *
@ -186,7 +162,7 @@ namespace Logger
inline QDebug& inline QDebug&
operator <<( QDebug& s, const DebugRow<T, U>& t ) operator <<( QDebug& s, const DebugRow<T, U>& t )
{ {
s << Continuation() << t.first << ':' << ' ' << t.second; s << Continuation << t.first << ':' << ' ' << t.second;
return s; return s;
} }
@ -195,7 +171,7 @@ namespace Logger
operator <<( QDebug& s, const DebugList& c ) operator <<( QDebug& s, const DebugList& c )
{ {
for( const auto& i : c.list ) for( const auto& i : c.list )
s << Continuation() << i; s << Continuation << i;
return s; return s;
} }
@ -207,7 +183,7 @@ namespace Logger
operator <<( QDebug& s, const DebugMap& t ) operator <<( QDebug& s, const DebugMap& t )
{ {
for ( auto it = t.map.constBegin(); it != t.map.constEnd(); ++it ) for ( auto it = t.map.constBegin(); it != t.map.constEnd(); ++it )
s << Continuation() << it.key().toUtf8().constData() << ':' << ' ' << toString( it.value() ).toUtf8().constData(); s << Continuation << it.key().toUtf8().constData() << ':' << ' ' << toString( it.value() ).toUtf8().constData();
return s; return s;
} }
} }