[libcalamares] Structure continuations and sub-entries

main
Adriaan de Groot 6 years ago
parent b6ea171365
commit 09ae721038

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

@ -2,7 +2,7 @@
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
* Copyright 2017-2019, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -27,7 +27,25 @@
namespace Logger
{
extern const char* continuation;
/** @brief tag-class used for continuing debug-output on the next line
*
* 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
{
@ -95,6 +113,13 @@ namespace Logger
/** @brief Would the given @p level really be logged? */
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.
*
@ -161,7 +186,7 @@ namespace Logger
inline QDebug&
operator <<( QDebug& s, const DebugRow<T, U>& t )
{
s << continuation << t.first << ':' << ' ' << t.second;
s << Continuation() << t.first << ':' << ' ' << t.second;
return s;
}
@ -170,7 +195,7 @@ namespace Logger
operator <<( QDebug& s, const DebugList& c )
{
for( const auto& i : c.list )
s << continuation << i;
s << Continuation() << i;
return s;
}
@ -182,7 +207,7 @@ namespace Logger
operator <<( QDebug& s, const DebugMap& t )
{
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;
}
}

Loading…
Cancel
Save