From deca010d62c94789ba856d048a00bf159cc9a444 Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Tue, 9 Oct 2012 18:03:31 +0200 Subject: Use slogger2 for logging on Blackberry instead of writing to stderr Backport from Qt5: c86ed49a7989adb3e2e3c42794e44609f12ce493 Change-Id: I09d84b08f7c90348b4104f7e52d76ee27a4837af Reviewed-by: Rafael Roquetto Reviewed-by: Thomas McGuire Reviewed-by: Peter Hartmann --- config.tests/unix/slog2/slog2.cpp | 48 +++++++++++++++++++++++++++++++++ config.tests/unix/slog2/slog2.pro | 4 +++ configure | 32 ++++++++++++++++++++++ src/corelib/global/global.pri | 5 ++++ src/corelib/global/qglobal.cpp | 57 +++++++++++++++++++++++++++++++++++++++ tools/configure/configureapp.cpp | 24 ++++++++++++++++- 6 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 config.tests/unix/slog2/slog2.cpp create mode 100644 config.tests/unix/slog2/slog2.pro diff --git a/config.tests/unix/slog2/slog2.cpp b/config.tests/unix/slog2/slog2.cpp new file mode 100644 index 0000000000..900d14a115 --- /dev/null +++ b/config.tests/unix/slog2/slog2.cpp @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2011 - 2012 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** This file is part of the config.tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +int main(int, char **) +{ + slog2_set_default_buffer((slog2_buffer_t)-1); + return 0; +} diff --git a/config.tests/unix/slog2/slog2.pro b/config.tests/unix/slog2/slog2.pro new file mode 100644 index 0000000000..9f5b34d664 --- /dev/null +++ b/config.tests/unix/slog2/slog2.pro @@ -0,0 +1,4 @@ +SOURCES = slog2.cpp +CONFIG -= qt +mac:CONFIG -= app_bundle +LIBS += -lslog2 diff --git a/configure b/configure index 08d9270a89..e3d464b9ee 100755 --- a/configure +++ b/configure @@ -917,6 +917,7 @@ CFG_ICD=auto CFG_NOPROCESS=no CFG_ICU=auto CFG_SYSTEM_PROXIES=no +CFG_SLOG2=auto # initalize variables used for installation QT_INSTALL_PREFIX= @@ -2100,6 +2101,13 @@ while [ "$#" -gt 0 ]; do UNKNOWN_OPT=yes fi ;; + slog2) + if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then + CFG_SLOG2="$VAL" + else + UNKNOWN_OPT=yes + fi + ;; gstreamer) if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then CFG_GSTREAMER="$VAL" @@ -4349,6 +4357,16 @@ Qt/X11 only: EOF fi +if [ "$XPLATFORM_QNX" = "yes" ]; then + cat << EOF + + -no-slog2 .......... Do not compile with slog2 support. + -slog2 ............. Compile with slog2 support. + +EOF + +fi + if [ "$PLATFORM_MAC" = "yes" ]; then cat << EOF @@ -5314,6 +5332,17 @@ if [ "$CFG_ZLIB" = "auto" ]; then fi fi +if [ "$XPLATFORM_QNX" = "yes" ]; then + if [ "$CFG_SLOG2" != "no" ]; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/slog2 "slog2" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then + CFG_SLOG2=yes + QMAKE_CONFIG="$QMAKE_CONFIG slog2" + else + CFG_SLOG2=no + fi + fi +fi + if [ "$CFG_LARGEFILE" = "auto" ]; then #Large files should be enabled for all Linux systems CFG_LARGEFILE=yes @@ -8930,6 +8959,9 @@ if [ "$CFG_MNG" = "no" ]; then else echo "MNG support ............ $CFG_MNG ($CFG_LIBMNG)" fi +if [ "$XPLATFORM_QNX" = "yes" ]; then + echo "SLOG2 support .......... $CFG_SLOG2" +fi echo "zlib support ........... $CFG_ZLIB" echo "Session management ..... $CFG_SM" if [ "$PLATFORM_QWS" = "yes" ]; then diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri index 68582bf2d5..dbd042ba56 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 79aafb46c8..b9297766f7 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -78,6 +78,11 @@ #include #endif +#ifdef QT_USE_SLOG2 +#include +#endif + + #if defined(Q_OS_SYMBIAN) #include #include @@ -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'); diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 77174d5d64..94107938e0 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -401,6 +401,7 @@ Configure::Configure(int& argc, char** argv) dictionary[ "NATIVE_GESTURES" ] = "yes"; dictionary[ "MSVC_MP" ] = "no"; dictionary[ "SYSTEM_PROXIES" ] = "no"; + dictionary[ "SLOG2" ] = "no"; } Configure::~Configure() @@ -1018,6 +1019,10 @@ void Configure::parseCmdLine() dictionary[ "PLUGIN_MANIFESTS" ] = "no"; } else if (configCmdLine.at(i) == "-plugin-manifests") { dictionary[ "PLUGIN_MANIFESTS" ] = "yes"; + } else if (configCmdLine.at(i) == "-no-slog2") { + dictionary[ "SLOG2" ] = "no"; + } else if (configCmdLine.at(i) == "-slog2") { + dictionary[ "SLOG2" ] = "yes"; } // Work around compiler nesting limitation @@ -1715,7 +1720,7 @@ void Configure::applySpecSpecifics() dictionary[ "QT_ICONV" ] = "no"; dictionary["DECORATIONS"] = "default windows styled"; - } else if (dictionary[ "XQMAKESPEC" ].contains("blackberry")) { //TODO actually wrong. + } else if (platform() == QNX || platform() == BLACKBERRY) { dictionary[ "STYLE_WINDOWSXP" ] = "no"; dictionary[ "STYLE_WINDOWSVISTA" ] = "no"; dictionary[ "STYLE_WINDOWSCE" ] = "no"; @@ -1742,6 +1747,7 @@ void Configure::applySpecSpecifics() dictionary[ "FONT_CONFIG" ] = "yes"; dictionary[ "FREETYPE" ] = "system"; dictionary[ "STACK_PROTECTOR_STRONG" ] = "auto"; + dictionary[ "SLOG2" ] = "auto"; } } @@ -1983,6 +1989,11 @@ bool Configure::displayHelp() desc("LIBJPEG", "qt", "-qt-libjpeg", "Use the libjpeg bundled with Qt."); desc("LIBJPEG", "system","-system-libjpeg", "Use libjpeg from the operating system.\nSee http://www.ijg.org\n"); + if (platform() == QNX || platform() == BLACKBERRY) { + desc("SLOG2", "yes", "-slog2", "Compile with slog2 support."); + desc("SLOG2", "no", "-no-slog2", "Do not compile with slog2 support."); + } + #endif // Qt\Windows only options go below here -------------------------------------------------------------------------------- desc("Qt for Windows only:\n\n"); @@ -2427,6 +2438,8 @@ bool Configure::checkAvailability(const QString &part) compilerAndArgs += "qcc"; compilerAndArgs += "-fstack-protector-strong"; available = dictionary[ "XQMAKESPEC" ].contains("blackberry") && compilerSupportsFlag(compilerAndArgs); + } else if (part == "SLOG2") { + available = findFile("slog2.h"); } return available; @@ -2534,6 +2547,10 @@ void Configure::autoDetection() if (dictionary["STACK_PROTECTOR_STRONG"] == "auto") dictionary["STACK_PROTECTOR_STRONG"] = checkAvailability("STACK_PROTECTOR_STRONG") ? "yes" : "no"; + if ((platform() == QNX || platform == BLACKBERRY) && dictionary["SLOG2"] == "auto") { + dictionary[ "SLOG2" ] = checkAvailability("SLOG2") ? "yes" : "no"; + } + // Mark all unknown "auto" to the default value.. for (QMap::iterator i = dictionary.begin(); i != dictionary.end(); ++i) { if (i.value() == "auto") @@ -3268,6 +3285,9 @@ void Configure::generateCachefile() if (dictionary["FONT_CONFIG"] == "yes") configStream << " fontconfig"; + if (dictionary[ "SLOG2" ] == "yes") + configStream << " slog2"; + if (dictionary.contains("SYMBIAN_DEFFILES")) { if (dictionary["SYMBIAN_DEFFILES"] == "yes") { configStream << " def_files"; @@ -3785,6 +3805,8 @@ void Configure::displayConfig() cout << " PNG support............." << dictionary[ "PNG" ] << endl; cout << " MNG support............." << dictionary[ "MNG" ] << endl; cout << " FreeType support........" << dictionary[ "FREETYPE" ] << endl << endl; + if (platform() == QNX || platform() == BLACKBERRY) + cout << " SLOG2 support..........." << dictionary[ "SLOG2" ] << endl; cout << "Styles:" << endl; cout << " Windows................." << dictionary[ "STYLE_WINDOWS" ] << endl; -- cgit v1.2.3