From: Debian Qt/KDE Maintainers Date: Fri, 1 May 2015 19:35:39 +0000 (+0000) Subject: qtdebug_syslog X-Git-Tag: archive/raspbian/4%4.8.6+git64-g5dc8b2b+dfsg-3+deb8u2+rpi1~1^2~40 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9ae98fb1e1fa00cedaffc94837821e2e7e2cb90e;p=qt4-x11.git qtdebug_syslog Gbp-Pq: Name qtdebug_syslog.patch --- diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index aaad58ea4..7412da288 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -50,6 +50,7 @@ #ifndef QT_NO_QOBJECT #include +#include #endif #include @@ -92,6 +93,8 @@ _LIT(qt_S60Filter, "Series60v?.*.sis"); _LIT(qt_symbianSystemInstallDir, "z:\\system\\install\\"); +#elif defined(Q_OS_UNIX) +#include #endif QT_BEGIN_NAMESPACE @@ -2327,6 +2330,27 @@ void qt_message_output(QtMsgType msgType, const char *buf) #else fprintf(stderr, "%s\n", buf); fflush(stderr); + + if (qgetenv("QT_USE_SYSLOG").toInt() > 0) { + static bool logOpened = false; + if (!logOpened) { + QByteArray appname; +#ifndef QT_NO_QOBJECT + appname = QCoreApplication::applicationName().toLatin1(); // don't use the local codec here + if (appname.isEmpty()) + appname = QCoreApplicationPrivate::staticAppName().toLatin1(); +#endif + if (appname.isEmpty()) + appname = "unknown-qt-application"; + openlog(appname, LOG_NOWAIT | LOG_PID, LOG_USER); + logOpened = true; + } + + int level = msgType == QtFatalMsg ? LOG_ERR : + msgType == QtWarningMsg ? LOG_WARNING : + LOG_DEBUG; + syslog(level, "%s", buf); + } #endif } diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index d370356dc..470a8a4ca 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -86,6 +86,8 @@ public: bool sendThroughObjectEventFilters(QObject *, QEvent *); bool notify_helper(QObject *, QEvent *); + static QString staticAppName() + { return QCoreApplication::self ? QCoreApplication::self->d_func()->appName() : QString(); } virtual QString appName() const; mutable QString applicationName;