From 432154e50ac8d51598a2d6507b097f18468892e0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 18 Jun 2021 16:10:13 +0200 Subject: [PATCH] [libcalamares] Improve Once-logging Sending a Once to a logger that isn't enabled should not "consume" that Once; it's still available for a subsequent logger that **is** enabled (useful if you're using more than one log-level in a function). --- src/libcalamares/utils/Logger.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libcalamares/utils/Logger.h b/src/libcalamares/utils/Logger.h index 8ef0edaf9..871cc6fb3 100644 --- a/src/libcalamares/utils/Logger.h +++ b/src/libcalamares/utils/Logger.h @@ -60,6 +60,8 @@ public: friend CDebug& operator<<( CDebug&&, const FuncSuppressor& ); friend CDebug& operator<<( CDebug&&, const Once& ); + inline unsigned int level() const { return m_debugLevel; } + private: QString m_msg; unsigned int m_debugLevel; @@ -315,6 +317,12 @@ private: inline CDebug& operator<<( CDebug&& s, const Once& o ) { + if ( !logLevelEnabled( s.level() ) ) + { + // This won't print, so it's not using the "onceness" + return s; + } + if ( o.m ) { o.m = false;