Support logging direct to syslog, if enabled.
[ChangeLog][QtCore][Logging] Systems with syslog may now pass -syslog to configure to send logging output to syslog. Change-Id: I80d58ee6e70d8deb2409fc666e7e7f2d7f52b8e1 Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>bb10
parent
89cb92f838
commit
26b4ec448c
|
|
@ -0,0 +1,42 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 Tasuku Suzuki <stasuku@gmail.com>
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the config.tests of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <syslog.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
openlog("qt", 0, LOG_USER);
|
||||
syslog(LOG_INFO, "configure");
|
||||
closelog();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
SOURCES = syslog.c
|
||||
|
||||
CONFIG -= qt
|
||||
|
|
@ -621,6 +621,7 @@ CFG_XFIXES=runtime
|
|||
CFG_ZLIB=auto
|
||||
CFG_MTDEV=auto
|
||||
CFG_JOURNALD=no
|
||||
CFG_SYSLOG=no
|
||||
CFG_SQLITE=qt
|
||||
CFG_GIF=auto
|
||||
CFG_PNG=yes
|
||||
|
|
@ -1700,6 +1701,13 @@ while [ "$#" -gt 0 ]; do
|
|||
UNKNOWN_OPT=yes
|
||||
fi
|
||||
;;
|
||||
syslog)
|
||||
if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
|
||||
CFG_SYSLOG="$VAL"
|
||||
else
|
||||
UNKNOWN_OPT=yes
|
||||
fi
|
||||
;;
|
||||
sqlite)
|
||||
if [ "$VAL" = "system" ]; then
|
||||
CFG_SQLITE=system
|
||||
|
|
@ -2472,6 +2480,9 @@ Third Party Libraries:
|
|||
+ -no-journald ........ Do not send logging output to journald.
|
||||
-journald ........... Send logging output to journald.
|
||||
|
||||
+ -no-syslog .......... Do not send logging output to syslog.
|
||||
-syslog ............. Send logging output to syslog.
|
||||
|
||||
-no-gif ............. Do not compile GIF reading support.
|
||||
|
||||
-no-libpng .......... Do not compile PNG support.
|
||||
|
|
@ -4557,6 +4568,23 @@ if [ "$CFG_JOURNALD" != "no" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
if [ "$CFG_SYSLOG" != "no" ]; then
|
||||
if compileTest unix/syslog "syslog"; then
|
||||
CFG_SYSLOG=yes
|
||||
QMAKE_CONFIG="$QMAKE_CONFIG syslog"
|
||||
else
|
||||
if [ "$CFG_SYSLOG" != "auto" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
|
||||
echo "syslog support cannot be enabled due to functionality tests!"
|
||||
echo " Turn on verbose messaging (-v) to $0 to see the final report."
|
||||
echo " If you believe this message is in error you may use the continue"
|
||||
echo " switch (-continue) to $0 to continue."
|
||||
exit 101
|
||||
else
|
||||
CFG_SYSLOG=no
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$CFG_LARGEFILE" = "auto" ]; then
|
||||
#Large files should be enabled for all Linux systems
|
||||
CFG_LARGEFILE=yes
|
||||
|
|
@ -7078,8 +7106,10 @@ report_support " Image formats:"
|
|||
report_support_plugin " GIF .................." "$CFG_GIF" qt QtGui
|
||||
report_support_plugin " JPEG ................." "$CFG_JPEG" "$CFG_LIBJPEG" QtGui
|
||||
report_support_plugin " PNG .................." "$CFG_PNG" "$CFG_LIBPNG" QtGui
|
||||
report_support " journald ..............." "$CFG_JOURNALD"
|
||||
report_support " libinput................" "$CFG_LIBINPUT"
|
||||
report_support " Logging backends:"
|
||||
report_support " journald ..............." "$CFG_JOURNALD"
|
||||
report_support " syslog ..............." "$CFG_SYSLOG"
|
||||
report_support " mtdev .................." "$CFG_MTDEV" yes "system library"
|
||||
report_support " Networking:"
|
||||
[ "$XPLATFORM_MAC" = "yes" ] && \
|
||||
|
|
@ -7169,12 +7199,12 @@ if [ "$CFG_OPENSSL" = "linked" ] && [ "$OPENSSL_LIBS" = "" ]; then
|
|||
echo "For example:"
|
||||
echo " OPENSSL_LIBS='-L/opt/ssl/lib -lssl -lcrypto' ./configure -openssl-linked"
|
||||
fi
|
||||
if [ "$CFG_JOURNALD" = "yes" ] || [ "$CFG_SLOG2" = "yes" ]; then
|
||||
if [ "$CFG_JOURNALD" = "yes" ] || [ "$CFG_SYSLOG" = "yes" ] || [ "$CFG_SLOG2" = "yes" ]; then
|
||||
echo
|
||||
echo "NOTE: journald or slog2 integration is enabled."
|
||||
echo "NOTE: journald, syslog or slog2 integration is enabled."
|
||||
echo "If your users intend on developing applications against this build,"
|
||||
echo "ensure that the IDEs they use either set QT_LOGGING_TO_CONSOLE to 1"
|
||||
echo "or the IDE is able to read the logged output from journald or slog2."
|
||||
echo "or the IDE is able to read the logged output from journald, syslog or slog2."
|
||||
fi
|
||||
if [ "$CFG_XKBCOMMON" = "qt" ] && [ "$CFG_XKB_CONFIG_ROOT" = "not found" ]; then
|
||||
echo
|
||||
|
|
|
|||
|
|
@ -54,3 +54,7 @@ journald {
|
|||
PKGCONFIG_PRIVATE += libsystemd-journal
|
||||
DEFINES += QT_USE_JOURNALD
|
||||
}
|
||||
|
||||
syslog {
|
||||
DEFINES += QT_USE_SYSLOG
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,9 @@
|
|||
# include <systemd/sd-journal.h>
|
||||
# include <syslog.h>
|
||||
#endif
|
||||
#if defined(QT_USE_SYSLOG) && !defined(QT_BOOTSTRAPPED)
|
||||
# include <syslog.h>
|
||||
#endif
|
||||
#ifdef Q_OS_UNIX
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
|
|
@ -1436,6 +1439,32 @@ static void systemd_default_message_handler(QtMsgType type,
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef QT_USE_SYSLOG
|
||||
static void syslog_default_message_handler(QtMsgType type, const char *message)
|
||||
{
|
||||
int priority = LOG_INFO; // Informational
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
priority = LOG_DEBUG; // Debug-level messages
|
||||
break;
|
||||
case QtInfoMsg:
|
||||
priority = LOG_INFO; // Informational conditions
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
priority = LOG_WARNING; // Warning conditions
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
priority = LOG_CRIT; // Critical conditions
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
priority = LOG_ALERT; // Action must be taken immediately
|
||||
break;
|
||||
}
|
||||
|
||||
syslog(priority, "%s", message);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
static void android_default_message_handler(QtMsgType type,
|
||||
const QMessageLogContext &context,
|
||||
|
|
@ -1481,6 +1510,9 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con
|
|||
#elif defined(QT_USE_JOURNALD) && !defined(QT_BOOTSTRAPPED)
|
||||
systemd_default_message_handler(type, context, logMessage);
|
||||
return;
|
||||
#elif defined(QT_USE_SYSLOG) && !defined(QT_BOOTSTRAPPED)
|
||||
syslog_default_message_handler(type, logMessage.toUtf8().constData());
|
||||
return;
|
||||
#elif defined(Q_OS_ANDROID)
|
||||
android_default_message_handler(type, context, logMessage);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in New Issue