diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h
index 0751387a4..5cb14311e 100644
--- a/include/libcamera/base/log.h
+++ b/include/libcamera/base/log.h
@@ -108,10 +108,22 @@ LogMessage _log(const LogCategory &category, LogSeverity severity,
 #ifndef __DOXYGEN__
 #define _LOG_CATEGORY(name) logCategory##name
 
-#define _LOG(cat, sev)                                                 \
-	switch (const auto &_logCategory = (cat);                      \
-		static_cast<int>(_logCategory.severity() <= Log##sev)) \
-	case 1:                                                        \
+/* Returns `int` to avoid `-Wswitch-bool` below. */
+template<LogSeverity Severity>
+constexpr int isLogSeverityEnabled(const LogCategory &category)
+{
+	static_assert(LogDebug <= Severity && Severity <= LogFatal);
+
+	if constexpr (Severity < LogFatal)
+		return static_cast<unsigned int>(category.severity()) <= Severity;
+	else
+		return true;
+}
+
+#define _LOG(cat, sev)                                        \
+	switch (const auto &_logCategory = (cat);             \
+		isLogSeverityEnabled<Log##sev>(_logCategory)) \
+	case 1:                                               \
 		_log(_logCategory, Log##sev).stream()
 
 #define _LOG1(severity) \
@@ -130,11 +142,11 @@ LogMessage _log(const LogCategory &category, LogSeverity severity,
 #endif /* __DOXYGEN__ */
 
 #ifndef NDEBUG
-#define ASSERT(condition) static_cast<void>(({                          \
-	if (!(condition))                                               \
-		_log(LogCategory::defaultCategory(), LogFatal).stream() \
-			<< "assertion \"" #condition "\" failed in "    \
-			<< __func__ << "()";                            \
+#define ASSERT(condition) static_cast<void>(({                       \
+	if (!(condition))                                            \
+		LOG(Fatal)                                           \
+			<< "assertion \"" #condition "\" failed in " \
+			<< __func__ << "()";                         \
 }))
 #else
 #define ASSERT(condition) static_cast<void>(false && (condition))
