[libcalamares] Convenience for logging subentries
For methods that log a bunch of things, and which want to consistently use SubEntry, but don't know when the **first** log entry is within the method, Logger::Once can be used to log one regular message (with function info) and the rest are subentries.
This commit is contained in:
parent
72f67286a4
commit
a90f510b85
@ -22,6 +22,8 @@
|
||||
|
||||
namespace Logger
|
||||
{
|
||||
class Once;
|
||||
|
||||
struct FuncSuppressor
|
||||
{
|
||||
explicit constexpr FuncSuppressor( const char[] );
|
||||
@ -58,6 +60,7 @@ public:
|
||||
virtual ~CDebug();
|
||||
|
||||
friend CDebug& operator<<( CDebug&&, const FuncSuppressor& );
|
||||
friend CDebug& operator<<( CDebug&&, Once& );
|
||||
|
||||
private:
|
||||
QString m_msg;
|
||||
@ -286,6 +289,33 @@ operator<<( QDebug& s, const Pointer& p )
|
||||
s << '@' << p.ptr << Quote;
|
||||
return s;
|
||||
}
|
||||
|
||||
class Once
|
||||
{
|
||||
public:
|
||||
Once()
|
||||
: m( true )
|
||||
{
|
||||
}
|
||||
friend CDebug& operator<<( CDebug&&, Once& );
|
||||
|
||||
private:
|
||||
bool m = false;
|
||||
};
|
||||
|
||||
inline CDebug&
|
||||
operator<<( CDebug&& s, Once& o )
|
||||
{
|
||||
if ( o.m )
|
||||
{
|
||||
o.m = false;
|
||||
return s;
|
||||
}
|
||||
s.m_funcinfo = nullptr;
|
||||
s << SubEntry;
|
||||
return s;
|
||||
}
|
||||
|
||||
} // namespace Logger
|
||||
|
||||
#define cDebug() Logger::CDebug( Logger::LOGDEBUG, Q_FUNC_INFO )
|
||||
|
@ -61,7 +61,6 @@ ModuleManager::init()
|
||||
QTimer::singleShot( 0, this, &ModuleManager::doInit );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ModuleManager::doInit()
|
||||
{
|
||||
@ -72,6 +71,7 @@ ModuleManager::doInit()
|
||||
// the module name, and must contain a settings file named module.desc.
|
||||
// If at any time the module loading procedure finds something unexpected, it
|
||||
// silently skips to the next module or search path. --Teo 6/2014
|
||||
Logger::Once deb;
|
||||
for ( const QString& path : m_paths )
|
||||
{
|
||||
QDir currentDir( path );
|
||||
@ -88,12 +88,12 @@ ModuleManager::doInit()
|
||||
QFileInfo descriptorFileInfo( currentDir.absoluteFilePath( QLatin1String( "module.desc" ) ) );
|
||||
if ( !descriptorFileInfo.exists() )
|
||||
{
|
||||
cDebug() << bad_descriptor << descriptorFileInfo.absoluteFilePath() << "(missing)";
|
||||
cDebug() << deb << bad_descriptor << descriptorFileInfo.absoluteFilePath() << "(missing)";
|
||||
continue;
|
||||
}
|
||||
if ( !descriptorFileInfo.isReadable() )
|
||||
{
|
||||
cDebug() << bad_descriptor << descriptorFileInfo.absoluteFilePath() << "(unreadable)";
|
||||
cDebug() << deb << bad_descriptor << descriptorFileInfo.absoluteFilePath() << "(unreadable)";
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -118,12 +118,12 @@ ModuleManager::doInit()
|
||||
}
|
||||
else
|
||||
{
|
||||
cDebug() << "ModuleManager module search path does not exist:" << path;
|
||||
cDebug() << deb << "ModuleManager module search path does not exist:" << path;
|
||||
}
|
||||
}
|
||||
// At this point m_availableDescriptorsByModuleName is filled with
|
||||
// the modules that were found in the search paths.
|
||||
cDebug() << "Found" << m_availableDescriptorsByModuleName.count() << "modules";
|
||||
cDebug() << deb << "Found" << m_availableDescriptorsByModuleName.count() << "modules";
|
||||
QTimer::singleShot( 10, this, &ModuleManager::initDone );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user