diff --git a/src/libcalamares/utils/Logger.h b/src/libcalamares/utils/Logger.h index a53ab7e19..f318c78a6 100644 --- a/src/libcalamares/utils/Logger.h +++ b/src/libcalamares/utils/Logger.h @@ -13,10 +13,13 @@ #ifndef UTILS_LOGGER_H #define UTILS_LOGGER_H -#include - #include "DllMacro.h" +#include +#include + +#include + namespace Logger { struct FuncSuppressor @@ -206,16 +209,34 @@ public: * Pointers are printed as void-pointer, so just an address (unlike, say, * QObject pointers which show an address and some metadata) preceded * by an '@'. This avoids C-style (void*) casts in the code. + * + * Shared pointers are indicated by 'S@' and unique pointers by 'U@'. */ struct Pointer { public: explicit Pointer( const void* p ) : ptr( p ) + , kind( 0 ) + { + } + + template < typename T > + explicit Pointer( const std::shared_ptr< T >& p ) + : ptr( p.get() ) + , kind( 'S' ) + { + } + + template < typename T > + explicit Pointer( const std::unique_ptr< T >& p ) + : ptr( p.get() ) + , kind( 'U' ) { } const void* const ptr; + const char kind; }; /** @brief output operator for DebugRow */ @@ -256,7 +277,12 @@ operator<<( QDebug& s, const DebugMap& t ) inline QDebug& operator<<( QDebug& s, const Pointer& p ) { - s << NoQuote << '@' << p.ptr << Quote; + s << NoQuote; + if ( p.kind ) + { + s << p.kind; + } + s << '@' << p.ptr << Quote; return s; } } // namespace Logger diff --git a/src/modules/partition/jobs/AutoMountManagementJob.cpp b/src/modules/partition/jobs/AutoMountManagementJob.cpp index 7ce3ac930..8078c17d5 100644 --- a/src/modules/partition/jobs/AutoMountManagementJob.cpp +++ b/src/modules/partition/jobs/AutoMountManagementJob.cpp @@ -25,7 +25,7 @@ AutoMountManagementJob::prettyName() const Calamares::JobResult AutoMountManagementJob::exec() { - Logger::CDebug(Logger::LOGVERBOSE) << "this" << Logger::Pointer( this ) << "value" << Logger::Pointer( m_stored.get() ); + Logger::CDebug(Logger::LOGVERBOSE) << "this" << Logger::Pointer( this ) << "value" << Logger::Pointer( m_stored ); if ( m_stored ) { CalamaresUtils::Partition::automountRestore( m_stored ); diff --git a/src/modules/partition/tests/AutoMountTests.cpp b/src/modules/partition/tests/AutoMountTests.cpp index f09cd3d97..87b6d5d4a 100644 --- a/src/modules/partition/tests/AutoMountTests.cpp +++ b/src/modules/partition/tests/AutoMountTests.cpp @@ -40,7 +40,7 @@ AutoMountJobTests::testRunThrice() Logger::setupLogLevel( Logger::LOGVERBOSE ); auto original = CalamaresUtils::Partition::automountDisable( true ); - cDebug() << "Got automount info" << Logger::Pointer( original.get() ); + cDebug() << "Got automount info" << Logger::Pointer( original ); AutoMountManagementJob j( false ); QVERIFY( j.exec() );