summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qlogging.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/global/qlogging.cpp')
-rw-r--r--src/corelib/global/qlogging.cpp114
1 files changed, 110 insertions, 4 deletions
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 8726c18689..52ffae5f98 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -83,7 +83,7 @@ QT_BEGIN_NAMESPACE
One example of direct use is to forward errors that stem from a scripting language, e.g. QML:
- \snippet doc/src/snippets/code/qlogging/qloggingsnippet.cpp 1
+ \snippet code/qlogging/qlogging.cpp 1
\sa QMessageLogContext, qDebug(), qWarning(), qCritical(), qFatal()
*/
@@ -159,7 +159,6 @@ static void qt_message(QtMsgType msgType, const QMessageLogContext &context, con
}
#undef qDebug
-
void QMessageLogger::debug(const char *msg, ...)
{
va_list ap;
@@ -205,7 +204,6 @@ QDebug QMessageLogger::warning()
#endif
#undef qCritical
-
void QMessageLogger::critical(const char *msg, ...)
{
va_list ap;
@@ -225,12 +223,14 @@ QDebug QMessageLogger::critical()
#endif
#undef qFatal
-
void QMessageLogger::fatal(const char *msg, ...)
{
va_list ap;
va_start(ap, msg); // use variable arg list
qt_message(QtFatalMsg, context, msg, ap);
+#ifndef Q_CC_MSVC
+ Q_UNREACHABLE();
+#endif
va_end(ap);
}
@@ -729,6 +729,112 @@ void qWinMessageHandler2(QtMsgType t, const QMessageLogContext &context,
}
#endif
+/*!
+ \typedef QtMsgHandler
+ \relates <QtGlobal>
+ \deprecated
+
+ This is a typedef for a pointer to a function with the following
+ signature:
+
+ \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 7
+
+ This typedef is deprecated, you should use QtMessageHandler instead.
+ \sa QtMsgType, QtMessageHandler, qInstallMsgHandler(), qInstallMessageHandler()
+*/
+
+/*!
+ \typedef QtMessageHandler
+ \relates <QtGlobal>
+ \since 5.0
+
+ This is a typedef for a pointer to a function with the following
+ signature:
+
+ \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 49
+
+ \sa QtMsgType, qInstallMessageHandler()
+*/
+
+/*!
+ \fn QtMessageHandler qInstallMessageHandler(QtMessageHandler handler)
+ \relates <QtGlobal>
+ \since 5.0
+
+ Installs a Qt message \a handler which has been defined
+ previously. Returns a pointer to the previous message handler
+ (which may be 0).
+
+ The message handler is a function that prints out debug messages,
+ warnings, critical and fatal error messages. The Qt library (debug
+ mode) contains hundreds of warning messages that are printed
+ when internal errors (usually invalid function arguments)
+ occur. Qt built in release mode also contains such warnings unless
+ QT_NO_WARNING_OUTPUT and/or QT_NO_DEBUG_OUTPUT have been set during
+ compilation. If you implement your own message handler, you get total
+ control of these messages.
+
+ The default message handler prints the message to the standard
+ output under X11 or to the debugger under Windows. If it is a
+ fatal message, the application aborts immediately.
+
+ Only one message handler can be defined, since this is usually
+ done on an application-wide basis to control debug output.
+
+ To restore the message handler, call \c qInstallMessageHandler(0).
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 23
+
+ \sa QtMessageHandler, QtMsgType, qDebug(), qWarning(), qCritical(), qFatal(),
+ {Debugging Techniques}
+*/
+
+/*!
+ \fn QtMsgHandler qInstallMsgHandler(QtMsgHandler handler)
+ \relates <QtGlobal>
+ \deprecated
+
+ Installs a Qt message \a handler which has been defined
+ previously. This method is deprecated, use qInstallMessageHandler
+ instead.
+ \sa QtMsgHandler, qInstallMessageHandler
+*/
+/*!
+ \fn void qSetMessagePattern(const QString &pattern)
+ \relates <QtGlobal>
+ \since 5.0
+
+ \brief Changes the output of the default message handler.
+
+ Allows to tweak the output of qDebug(), qWarning(), qCritical() and qFatal().
+
+ Following placeholders are supported:
+
+ \table
+ \header \li Placeholder \li Description
+ \row \li \c %{appname} \li QCoreApplication::applicationName()
+ \row \li \c %{file} \li Path to source file
+ \row \li \c %{function} \li Function
+ \row \li \c %{line} \li Line in source file
+ \row \li \c %{message} \li The actual message
+ \row \li \c %{pid} \li QCoreApplication::applicationPid()
+ \row \li \c %{threadid} \li ID of current thread
+ \row \li \c %{type} \li "debug", "warning", "critical" or "fatal"
+ \endtable
+
+ The default pattern is "%{message}".
+
+ The pattern can also be changed at runtime by setting the QT_MESSAGE_PATTERN
+ environment variable; if both qSetMessagePattern() is called and QT_MESSAGE_PATTERN is
+ set, the environment variable takes precedence.
+
+ qSetMessagePattern() has no effect if a custom message handler is installed.
+
+ \sa qInstallMessageHandler, Debugging Techniques
+ */
+
QtMessageHandler qInstallMessageHandler(QtMessageHandler h)
{
if (!messageHandler)