summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorFabian Bumberger <fbumberger@rim.com>2012-10-09 16:03:31 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-08 13:51:17 (GMT)
commitdeca010d62c94789ba856d048a00bf159cc9a444 (patch)
tree5a57c9ac2b9b96824263da1534cab1914441122e /src/corelib
parent5a9cdc701e6f7a5e9af09dddad9ca3a4834c252b (diff)
downloadQt-deca010d62c94789ba856d048a00bf159cc9a444.zip
Qt-deca010d62c94789ba856d048a00bf159cc9a444.tar.gz
Qt-deca010d62c94789ba856d048a00bf159cc9a444.tar.bz2
Use slogger2 for logging on Blackberry instead of writing to stderr
Backport from Qt5: c86ed49a7989adb3e2e3c42794e44609f12ce493 Change-Id: I09d84b08f7c90348b4104f7e52d76ee27a4837af Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com> Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com> Reviewed-by: Peter Hartmann <phartmann@rim.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/global.pri5
-rw-r--r--src/corelib/global/qglobal.cpp57
2 files changed, 62 insertions, 0 deletions
diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri
index 68582bf..dbd042b 100644
--- a/src/corelib/global/global.pri
+++ b/src/corelib/global/global.pri
@@ -31,4 +31,9 @@ symbian {
S60_VERSION_$$upper($$replace(S60_VERSION,\\.,_))
}
+slog2 {
+ LIBS_PRIVATE += -lslog2
+ DEFINES += QT_USE_SLOG2
+}
+
include(../../../tools/shared/symbian/epocroot.pri)
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 79aafb4..b929776 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -78,6 +78,11 @@
#include <CoreServices/CoreServices.h>
#endif
+#ifdef QT_USE_SLOG2
+#include <slog2.h>
+#endif
+
+
#if defined(Q_OS_SYMBIAN)
#include <e32def.h>
#include <e32debug.h>
@@ -2076,6 +2081,56 @@ static void mac_default_handler(const char *msg)
}
#endif // Q_CC_MWERKS && Q_OS_MACX
+#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
+
#if !defined(Q_OS_WIN) && !defined(QT_NO_THREAD) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) && \
defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L
namespace {
@@ -2215,6 +2270,8 @@ void qt_message_output(QtMsgType msgType, const char *buf)
} else {
#if defined(Q_CC_MWERKS) && defined(Q_OS_MACX)
mac_default_handler(buf);
+#elif defined(QT_USE_SLOG2)
+ slog2_default_handler(msgType, buf);
#elif defined(Q_OS_WINCE)
QString fstr = QString::fromLatin1(buf);
fstr += QLatin1Char('\n');