Merge branch 'improve-logger'
This commit is contained in:
commit
81bd173b7e
@ -44,7 +44,7 @@ requireString( const YAML::Node& config, const char* key )
|
||||
return QString::fromStdString( v.as< std::string >() );
|
||||
else
|
||||
{
|
||||
cWarning() << Logger::SubEntry() << "Required settings.conf key" << key << "is missing.";
|
||||
cWarning() << Logger::SubEntry << "Required settings.conf key" << key << "is missing.";
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
@ -58,7 +58,7 @@ requireBool( const YAML::Node& config, const char* key, bool d )
|
||||
return v.as< bool >();
|
||||
else
|
||||
{
|
||||
cWarning() << Logger::SubEntry() << "Required settings.conf key" << key << "is missing.";
|
||||
cWarning() << Logger::SubEntry << "Required settings.conf key" << key << "is missing.";
|
||||
return d;
|
||||
}
|
||||
}
|
||||
@ -106,7 +106,7 @@ interpretModulesSearch( const bool debugMode, const QStringList& rawPaths, QStri
|
||||
output.append( d.absolutePath() );
|
||||
}
|
||||
else
|
||||
cDebug() << Logger::SubEntry() << "module-search entry non-existent" << path;
|
||||
cDebug() << Logger::SubEntry << "module-search entry non-existent" << path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -189,36 +189,8 @@ CDebug::~CDebug()
|
||||
{
|
||||
}
|
||||
|
||||
static const char continuation[] = "\n ";
|
||||
static 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;
|
||||
}
|
||||
const char Continuation[] = "\n ";
|
||||
const char SubEntry[] = " .. ";
|
||||
|
||||
QString toString( const QVariant& v )
|
||||
{
|
||||
|
@ -27,25 +27,8 @@
|
||||
|
||||
namespace Logger
|
||||
{
|
||||
/** @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
|
||||
{
|
||||
} ;
|
||||
DLLEXPORT extern const char Continuation[];
|
||||
DLLEXPORT extern const char SubEntry[];
|
||||
|
||||
enum
|
||||
{
|
||||
@ -113,13 +96,6 @@ 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.
|
||||
*
|
||||
@ -186,7 +162,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;
|
||||
}
|
||||
|
||||
@ -195,7 +171,7 @@ namespace Logger
|
||||
operator <<( QDebug& s, const DebugList& c )
|
||||
{
|
||||
for( const auto& i : c.list )
|
||||
s << Continuation() << i;
|
||||
s << Continuation << i;
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -207,7 +183,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;
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ QList< Device* > getDevices( DeviceType which, qint64 minimumSize )
|
||||
#ifdef DEBUG_PARTITION_UNSAFE
|
||||
cWarning() << "Allowing unsafe partitioning choices." << devices.count() << "candidates.";
|
||||
#ifdef DEBUG_PARTITION_LAME
|
||||
cDebug() << Logger::SubEntry() << "it has been lamed, and will fail.";
|
||||
cDebug() << Logger::SubEntry << "it has been lamed, and will fail.";
|
||||
#endif
|
||||
#else
|
||||
cDebug() << "Removing unsuitable devices:" << devices.count() << "candidates.";
|
||||
@ -125,29 +125,29 @@ QList< Device* > getDevices( DeviceType which, qint64 minimumSize )
|
||||
for ( DeviceList::iterator it = devices.begin(); it != devices.end(); )
|
||||
if ( !( *it ) )
|
||||
{
|
||||
cDebug() << Logger::SubEntry() << "Skipping nullptr device";
|
||||
cDebug() << Logger::SubEntry << "Skipping nullptr device";
|
||||
it = erase( devices, it);
|
||||
}
|
||||
else if ( ( *it )->deviceNode().startsWith( "/dev/zram" )
|
||||
)
|
||||
{
|
||||
cDebug() << Logger::SubEntry() << "Removing zram" << it;
|
||||
cDebug() << Logger::SubEntry << "Removing zram" << it;
|
||||
it = erase( devices, it );
|
||||
|
||||
}
|
||||
else if ( writableOnly && hasRootPartition( *it ) )
|
||||
{
|
||||
cDebug() << Logger::SubEntry() << "Removing device with root filesystem (/) on it" << it;
|
||||
cDebug() << Logger::SubEntry << "Removing device with root filesystem (/) on it" << it;
|
||||
it = erase( devices, it );
|
||||
}
|
||||
else if ( writableOnly && isIso9660( *it ) )
|
||||
{
|
||||
cDebug() << Logger::SubEntry() << "Removing device with iso9660 filesystem (probably a CD) on it" << it;
|
||||
cDebug() << Logger::SubEntry << "Removing device with iso9660 filesystem (probably a CD) on it" << it;
|
||||
it = erase( devices, it );
|
||||
}
|
||||
else if ( (minimumSize >= 0) && !( (*it)->capacity() > minimumSize ) )
|
||||
{
|
||||
cDebug() << Logger::SubEntry() << "Removing too-small" << it;
|
||||
cDebug() << Logger::SubEntry << "Removing too-small" << it;
|
||||
it = erase( devices, it );
|
||||
}
|
||||
else
|
||||
|
@ -109,20 +109,20 @@ canBeResized( Partition* candidate )
|
||||
if ( !candidate->fileSystem().supportGrow() ||
|
||||
!candidate->fileSystem().supportShrink() )
|
||||
{
|
||||
cDebug() << Logger::SubEntry() << "NO, filesystem" << candidate->fileSystem().name()
|
||||
cDebug() << Logger::SubEntry << "NO, filesystem" << candidate->fileSystem().name()
|
||||
<< "does not support resize.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( KPMHelpers::isPartitionFreeSpace( candidate ) )
|
||||
{
|
||||
cDebug() << Logger::SubEntry() << "NO, partition is free space";
|
||||
cDebug() << Logger::SubEntry << "NO, partition is free space";
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( candidate->isMounted() )
|
||||
{
|
||||
cDebug() << Logger::SubEntry() << "NO, partition is mounted";
|
||||
cDebug() << Logger::SubEntry << "NO, partition is mounted";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -131,13 +131,13 @@ canBeResized( Partition* candidate )
|
||||
PartitionTable* table = dynamic_cast< PartitionTable* >( candidate->parent() );
|
||||
if ( !table )
|
||||
{
|
||||
cDebug() << Logger::SubEntry() << "NO, no partition table found";
|
||||
cDebug() << Logger::SubEntry << "NO, no partition table found";
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( table->numPrimaries() >= table->maxPrimaries() )
|
||||
{
|
||||
cDebug() << Logger::SubEntry() << "NO, partition table already has"
|
||||
cDebug() << Logger::SubEntry << "NO, partition table already has"
|
||||
<< table->maxPrimaries() << "primary partitions.";
|
||||
return false;
|
||||
}
|
||||
@ -164,10 +164,10 @@ canBeResized( Partition* candidate )
|
||||
else if ( ok )
|
||||
{
|
||||
auto deb = cDebug();
|
||||
deb << Logger::SubEntry() << "NO, insufficient storage";
|
||||
deb << Logger::Continuation() << "Required storage B:" << advisedStorageB
|
||||
deb << Logger::SubEntry << "NO, insufficient storage";
|
||||
deb << Logger::Continuation << "Required storage B:" << advisedStorageB
|
||||
<< QString( "(%1GB)" ).arg( advisedStorageGB );
|
||||
deb << Logger::Continuation() << "Available storage B:" << availableStorageB
|
||||
deb << Logger::Continuation << "Available storage B:" << availableStorageB
|
||||
<< QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 )
|
||||
<< "for" << convenienceName( candidate ) << " length:" << candidate->length()
|
||||
<< " sectorsUsed:" << candidate->sectorsUsed() << " fsType:" << candidate->fileSystem().name();
|
||||
@ -175,7 +175,7 @@ canBeResized( Partition* candidate )
|
||||
}
|
||||
else
|
||||
{
|
||||
cDebug() << Logger::SubEntry() << "NO, requiredStorageGB is not set correctly.";
|
||||
cDebug() << Logger::SubEntry << "NO, requiredStorageGB is not set correctly.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -198,10 +198,10 @@ canBeResized( PartitionCoreModule* core, const QString& partitionPath )
|
||||
return canBeResized( candidate );
|
||||
}
|
||||
}
|
||||
cDebug() << Logger::SubEntry() << "no Partition* found for" << partitionWithOs;
|
||||
cDebug() << Logger::SubEntry << "no Partition* found for" << partitionWithOs;
|
||||
}
|
||||
|
||||
cDebug() << Logger::SubEntry() << "Partition" << partitionWithOs << "CANNOT BE RESIZED FOR AUTOINSTALL.";
|
||||
cDebug() << Logger::SubEntry << "Partition" << partitionWithOs << "CANNOT BE RESIZED FOR AUTOINSTALL.";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1238,12 +1238,12 @@ ChoicePage::setupActions()
|
||||
{
|
||||
if ( PartUtils::canBeResized( *it ) )
|
||||
{
|
||||
cDebug() << Logger::SubEntry() << "contains resizable" << it;
|
||||
cDebug() << Logger::SubEntry << "contains resizable" << it;
|
||||
atLeastOneCanBeResized = true;
|
||||
}
|
||||
if ( PartUtils::canBeReplaced( *it ) )
|
||||
{
|
||||
cDebug() << Logger::SubEntry() << "contains replaceable" << it;
|
||||
cDebug() << Logger::SubEntry << "contains replaceable" << it;
|
||||
atLeastOneCanBeReplaced = true;
|
||||
}
|
||||
if ( (*it)->isMounted() )
|
||||
|
Loading…
Reference in New Issue
Block a user