summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2022-12-02 17:53:27 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2022-12-05 04:15:39 +0100
commiteb63f2eb0522531d133e96707f828dfc686698f4 (patch)
tree6c785847e2fe9bde2336bdca75aac21c09348257 /src/corelib/io
parent33e682f9af81902b36afa1aef1c4ecdcd2ed95a2 (diff)
QMessageLogger: make qFatal categorized and streamable
There is no technical reason why qFatal shouldn't support categorized logging, nor have a streaming version. There is perhaps an API issue, that is, a streaming syntax may encourage users to do "too much": qFatal() << gatherLogs() << saveDatabase() << ...; and that sounds like a bad idea in case the application is in an unrecoverable state that requires immedate terminatation (indeed, through qFatal). I'd err on the side of providing the extra convenience. This commits adds overloads of QMessageLogger::fatal to support categorized logging (note that fatal messages cannot be disabled), the relative qCFatal macro, as well as overloads for streaming. [ChangeLog][QtCore][QMessageLogger] QMessageLogger::fatal now supports categorized logging, for instance using the qCFatal(category) macro. Moreover, qFatal() and qCFatal() now support streaming of values to be printed in the fatal message. Change-Id: Ia57f25f5c85fca97e5fcf27eaa760dbde09cba0e Fixes: QTBUG-8298 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qloggingcategory.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/io/qloggingcategory.h b/src/corelib/io/qloggingcategory.h
index f990d8d0c4..c9b32a7227 100644
--- a/src/corelib/io/qloggingcategory.h
+++ b/src/corelib/io/qloggingcategory.h
@@ -125,6 +125,7 @@ template <> const bool QLoggingCategoryMacroHolder<QtWarningMsg>::IsOutputEnable
#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