summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorFabian Bumberger <fbumberger@rim.com>2012-09-18 14:15:18 -0400
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-04 14:25:47 +0200
commitc86ed49a7989adb3e2e3c42794e44609f12ce493 (patch)
treec76cf967541b294fcaff4a1d0e7cfda21de88a00 /src/corelib/global
parentc1197677901648893856084178291078035f2bc2 (diff)
Use slogger2 for logging on Blackberry instead of writing to stderr
Change-Id: Id0137400f18c8dfe7be7ca44670c16615401d424 Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com> Reviewed-by: Peter Hartmann <phartmann@rim.com>
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/global.pri4
-rw-r--r--src/corelib/global/qglobal.cpp12
-rw-r--r--src/corelib/global/qlogging.cpp58
3 files changed, 69 insertions, 5 deletions
diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri
index 28a1a390b7..05a2461f1b 100644
--- a/src/corelib/global/global.pri
+++ b/src/corelib/global/global.pri
@@ -35,3 +35,7 @@ linux*:!cross_compile:!static:!*-armcc* {
DEFINES += ELF_INTERPRETER=\\\"$$system(readelf -l /bin/ls | perl -n -e \'$$prog\')\\\"
}
+slog2 {
+ LIBS_PRIVATE += -lslog2
+ DEFINES += QT_USE_SLOG2
+}
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 805868f4c6..c1501db33d 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -2976,10 +2976,9 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
Calls the message handler with the debug message \a message. If no
message handler has been installed, the message is printed to
stderr. Under Windows, the message is sent to the console, if it is a
- console application; otherwise, it is sent to the debugger. This
- function does nothing if \c QT_NO_DEBUG_OUTPUT was defined
- during compilation.
-
+ console application; otherwise, it is sent to the debugger. On Blackberry the
+ message is sent to slogger2. This function does nothing if \c QT_NO_DEBUG_OUTPUT
+ was defined during compilation.
If you pass the function a format string and a list of arguments,
it works in similar way to the C printf() function. The format
@@ -3012,7 +3011,8 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
Calls the message handler with the warning message \a message. If no
message handler has been installed, the message is printed to
- stderr. Under Windows, the message is sent to the debugger. This
+ stderr. Under Windows, the message is sent to the debugger.
+ On Blackberry the message is sent to slogger2. This
function does nothing if \c QT_NO_WARNING_OUTPUT was defined
during compilation; it exits if the environment variable \c
QT_FATAL_WARNINGS is defined.
@@ -3046,6 +3046,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
Calls the message handler with the critical message \a message. If no
message handler has been installed, the message is printed to
stderr. Under Windows, the message is sent to the debugger.
+ On Blackberry the message is sent to slogger2.
This function takes a format string and a list of arguments,
similar to the C printf() function. The format should be a Latin-1
@@ -3076,6 +3077,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
Calls the message handler with the fatal message \a message. If no
message handler has been installed, the message is printed to
stderr. Under Windows, the message is sent to the debugger.
+ On Blackberry the message is sent to slogger2.
If you are using the \b{default message handler} this function will
abort on Unix systems to create a core dump. On Windows, for debug builds,
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index aec7111207..13bbdbead0 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -53,6 +53,9 @@
#ifdef Q_OS_WIN
#include <qt_windows.h>
#endif
+#ifdef QT_USE_SLOG2
+#include <slog2.h>
+#endif
#include <stdio.h>
@@ -660,6 +663,56 @@ void QMessagePattern::setPattern(const QString &pattern)
memcpy(literals, literalsVar.constData(), literalsVar.size() * sizeof(const char*));
}
+#if defined(QT_USE_SLOG2)
+#ifndef QT_LOG_CODE
+#define QT_LOG_CODE 9000
+#endif
+
+extern char *__progname;
+
+static void slog2_default_handler(QtMsgType msgType, const char *message)
+{
+ if (slog2_set_default_buffer((slog2_buffer_t)-1) == 0) {
+ slog2_buffer_set_config_t buffer_config;
+ slog2_buffer_t buffer_handle;
+
+ buffer_config.buffer_set_name = __progname;
+ buffer_config.num_buffers = 1;
+ buffer_config.verbosity_level = SLOG2_INFO;
+ buffer_config.buffer_config[0].buffer_name = "default";
+ buffer_config.buffer_config[0].num_pages = 8;
+
+ if (slog2_register(&buffer_config, &buffer_handle, 0) == -1) {
+ fprintf(stderr, "Error registering slogger2 buffer!\n");
+ fprintf(stderr, "%s", message);
+ fflush(stderr);
+ return;
+ }
+
+ // Set as the default buffer
+ slog2_set_default_buffer(buffer_handle);
+ }
+ int severity;
+ //Determines the severity level
+ switch (msgType) {
+ case QtDebugMsg:
+ severity = SLOG2_INFO;
+ break;
+ case QtWarningMsg:
+ severity = SLOG2_NOTICE;
+ break;
+ case QtCriticalMsg:
+ severity = SLOG2_WARNING;
+ break;
+ case QtFatalMsg:
+ severity = SLOG2_ERROR;
+ break;
+ }
+ //writes to the slog2 buffer
+ slog2c(NULL, QT_LOG_CODE, severity, message);
+}
+#endif // QT_USE_SLOG2
+
Q_GLOBAL_STATIC(QMessagePattern, qMessagePattern)
/*!
@@ -747,8 +800,13 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con
return;
}
#endif // Q_OS_WIN
+
+#if defined(QT_USE_SLOG2)
+ slog2_default_handler(type, logMessage.toLocal8Bit().constData());
+#else
fprintf(stderr, "%s", logMessage.toLocal8Bit().constData());
fflush(stderr);
+#endif
}
/*!