[libcalamares][partition] Give RedactedName a convert-to-QString

- use hex-trailer
- while here, convert DebugRow to use a copy rather than a reference,
  to avoid dangling references when applied to temporaries
- convert *partition* module to use the RedactedNames
This commit is contained in:
Adriaan de Groot 2021-11-16 14:54:09 +01:00
parent 152b3c333b
commit 5a4e2b73ab
4 changed files with 20 additions and 12 deletions

View File

@ -278,10 +278,9 @@ RedactedName::RedactedName(const char *context, const QString& s )
{ {
} }
QDebug& RedactedName::operator QString() const
operator<< ( QDebug& s, const RedactedName& n )
{ {
return s << NoQuote << n.m_context << '$' << n.m_id << Quote; return QString( m_context + '$' + QString::number( m_id, 16 ) );
} }
} // namespace Logger } // namespace Logger

View File

@ -145,8 +145,8 @@ public:
{ {
} }
const T& first; const T first;
const U& second; const U second;
}; };
/** /**
@ -237,11 +237,17 @@ struct RedactedName
RedactedName( const char* context, const QString& s ); RedactedName( const char* context, const QString& s );
RedactedName( const QString& context, const QString& s ); RedactedName( const QString& context, const QString& s );
operator QString() const;
private:
const uint m_id; const uint m_id;
const QString m_context; const QString m_context;
}; };
QDebug& operator<<( QDebug& s, const RedactedName& n ); inline QDebug& operator<<( QDebug& s, const RedactedName& n )
{
return s << NoQuote << QString( n ) << Quote;
}
/** /**
* @brief Formatted logging of a pointer * @brief Formatted logging of a pointer

View File

@ -262,8 +262,11 @@ PartitionCoreModule::doInit()
// Gives ownership of the Device* to the DeviceInfo object // Gives ownership of the Device* to the DeviceInfo object
auto deviceInfo = new DeviceInfo( device ); auto deviceInfo = new DeviceInfo( device );
m_deviceInfos << deviceInfo; m_deviceInfos << deviceInfo;
cDebug() << Logger::SubEntry << device->deviceNode() << device->capacity() << device->name() cDebug() << Logger::SubEntry
<< device->prettyName(); << device->deviceNode()
<< device->capacity()
<< Logger::RedactedName( "DevName", device->name() )
<< Logger::RedactedName( "DevNamePretty", device->prettyName() );
} }
else else
{ {

View File

@ -104,17 +104,17 @@ mapForPartition( Partition* partition, const QString& uuid )
// Debugging for inside the loop in createPartitionList(), // Debugging for inside the loop in createPartitionList(),
// so indent a bit // so indent a bit
Logger::CDebug deb; Logger::CDebug deb;
using TR = Logger::DebugRow< const char* const, const QString& >; using TR = Logger::DebugRow< const char* const, const QString >;
// clang-format off // clang-format off
deb << Logger::SubEntry << "mapping for" << partition->partitionPath() << partition->deviceNode() deb << Logger::SubEntry << "mapping for" << partition->partitionPath() << partition->deviceNode()
<< TR( "partlabel", map[ "partlabel" ].toString() ) << TR( "partlabel", map[ "partlabel" ].toString() )
<< TR( "partition-uuid (partuuid)", map[ "partuuid" ].toString() ) << TR( "partition-uuid (partuuid)", Logger::RedactedName( "PartUUID", map[ "partuuid" ].toString() ) )
<< TR( "parttype", map[ "parttype" ].toString() ) << TR( "parttype", map[ "parttype" ].toString() )
<< TR( "partattrs", map[ "partattrs" ].toString() ) << TR( "partattrs", map[ "partattrs" ].toString() )
<< TR( "mountPoint:", PartitionInfo::mountPoint( partition ) ) << TR( "mountPoint:", PartitionInfo::mountPoint( partition ) )
<< TR( "fs:", map[ "fs" ].toString() ) << TR( "fs:", map[ "fs" ].toString() )
<< TR( "fsName", map[ "fsName" ].toString() ) << TR( "fsName", map[ "fsName" ].toString() )
<< TR( "filesystem-uuid (uuid)", uuid ) << TR( "filesystem-uuid (uuid)", Logger::RedactedName( "FSUUID", uuid ) )
<< TR( "claimed", map[ "claimed" ].toString() ); << TR( "claimed", map[ "claimed" ].toString() );
// clang-format on // clang-format on
if ( partition->roles().has( PartitionRole::Luks ) ) if ( partition->roles().has( PartitionRole::Luks ) )