summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qloggingcategory.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qloggingcategory.h')
-rw-r--r--src/corelib/io/qloggingcategory.h35
1 files changed, 12 insertions, 23 deletions
diff --git a/src/corelib/io/qloggingcategory.h b/src/corelib/io/qloggingcategory.h
index 60773bd2a9..7c32beea1a 100644
--- a/src/corelib/io/qloggingcategory.h
+++ b/src/corelib/io/qloggingcategory.h
@@ -19,17 +19,11 @@ public:
bool isEnabled(QtMsgType type) const;
void setEnabled(QtMsgType type, bool enable);
-#ifdef Q_ATOMIC_INT8_IS_SUPPORTED
bool isDebugEnabled() const { return bools.enabledDebug.loadRelaxed(); }
bool isInfoEnabled() const { return bools.enabledInfo.loadRelaxed(); }
bool isWarningEnabled() const { return bools.enabledWarning.loadRelaxed(); }
bool isCriticalEnabled() const { return bools.enabledCritical.loadRelaxed(); }
-#else
- bool isDebugEnabled() const { return enabled.loadRelaxed() >> DebugShift & 1; }
- bool isInfoEnabled() const { return enabled.loadRelaxed() >> InfoShift & 1; }
- bool isWarningEnabled() const { return enabled.loadRelaxed() >> WarningShift & 1; }
- bool isCriticalEnabled() const { return enabled.loadRelaxed() >> CriticalShift & 1; }
-#endif
+
const char *categoryName() const { return name; }
// allows usage of both factory method and variable in qCX macros
@@ -49,19 +43,11 @@ private:
Q_DECL_UNUSED_MEMBER void *d; // reserved for future use
const char *name;
-#ifdef Q_BIG_ENDIAN
- enum { DebugShift = 0, WarningShift = 8, CriticalShift = 16, InfoShift = 24 };
-#else
- enum { DebugShift = 24, WarningShift = 16, CriticalShift = 8, InfoShift = 0};
-#endif
-
struct AtomicBools {
-#ifdef Q_ATOMIC_INT8_IS_SUPPORTED
QBasicAtomicInteger<bool> enabledDebug;
QBasicAtomicInteger<bool> enabledWarning;
QBasicAtomicInteger<bool> enabledCritical;
QBasicAtomicInteger<bool> enabledInfo;
-#endif
};
union {
AtomicBools bools;
@@ -81,11 +67,6 @@ template <QtMsgType Which> struct QLoggingCategoryMacroHolder
if (IsOutputEnabled)
init(cat);
}
- explicit QLoggingCategoryMacroHolder(QMessageLogger::CategoryFunction catfunc)
- {
- if (IsOutputEnabled)
- init(catfunc());
- }
void init(const QLoggingCategory &cat) noexcept
{
category = &cat;
@@ -98,8 +79,12 @@ template <QtMsgType Which> struct QLoggingCategoryMacroHolder
control = cat.isInfoEnabled();
} else if constexpr (Which == QtWarningMsg) {
control = cat.isWarningEnabled();
- } else {
+ } else if constexpr (Which == QtCriticalMsg) {
control = cat.isCriticalEnabled();
+ } else if constexpr (Which == QtFatalMsg) {
+ control = true;
+ } else {
+ static_assert(QtPrivate::value_dependent_false<Which>(), "Unknown Qt message type");
}
}
const char *name() const { return category->categoryName(); }
@@ -119,7 +104,10 @@ template <> const bool QLoggingCategoryMacroHolder<QtWarningMsg>::IsOutputEnable
} // unnamed namespace
#define Q_DECLARE_LOGGING_CATEGORY(name) \
- extern const QLoggingCategory &name();
+ const QLoggingCategory &name();
+
+#define Q_DECLARE_EXPORTED_LOGGING_CATEGORY(name, export_macro) \
+ export_macro Q_DECLARE_LOGGING_CATEGORY(name)
#define Q_LOGGING_CATEGORY(name, ...) \
const QLoggingCategory &name() \
@@ -129,13 +117,14 @@ template <> const bool QLoggingCategoryMacroHolder<QtWarningMsg>::IsOutputEnable
}
#define QT_MESSAGE_LOGGER_COMMON(category, level) \
- for (QLoggingCategoryMacroHolder<level> qt_category(category); qt_category; qt_category.control = false) \
+ for (QLoggingCategoryMacroHolder<level> qt_category((category)()); qt_category; qt_category.control = false) \
QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, qt_category.name())
#define qCDebug(category, ...) QT_MESSAGE_LOGGER_COMMON(category, QtDebugMsg).debug(__VA_ARGS__)
#define qCInfo(category, ...) QT_MESSAGE_LOGGER_COMMON(category, QtInfoMsg).info(__VA_ARGS__)
#define qCWarning(category, ...) QT_MESSAGE_LOGGER_COMMON(category, QtWarningMsg).warning(__VA_ARGS__)
#define qCCritical(category, ...) QT_MESSAGE_LOGGER_COMMON(category, QtCriticalMsg).critical(__VA_ARGS__)
+#define qCFatal(category, ...) QT_MESSAGE_LOGGER_COMMON(category, QtFatalMsg).fatal(__VA_ARGS__)
QT_END_NAMESPACE