summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--service-quasselcore/patches/net-irc/quassel/syslog-fixes.patch111
1 files changed, 72 insertions, 39 deletions
diff --git a/service-quasselcore/patches/net-irc/quassel/syslog-fixes.patch b/service-quasselcore/patches/net-irc/quassel/syslog-fixes.patch
index d687355..87f41a4 100644
--- a/service-quasselcore/patches/net-irc/quassel/syslog-fixes.patch
+++ b/service-quasselcore/patches/net-irc/quassel/syslog-fixes.patch
@@ -1,31 +1,66 @@
-From 88ae37a3059f906e397aa49ee3b204e16f24ab87 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Wolfgang=20M=C3=BCller?= <vehk@vehk.de>
-Date: Fri, 11 Jan 2019 16:45:52 +0000
-Subject: [PATCH] logger: Make output to syslog nicer
-
----
- src/common/logger.cpp | 41 ++++++++++++++++++++++++-----------------
- 1 file changed, 24 insertions(+), 17 deletions(-)
-
diff --git a/src/common/logger.cpp b/src/common/logger.cpp
-index b37abc29c..697d090c1 100644
+index b37abc29..80cec4b2 100644
--- a/src/common/logger.cpp
+++ b/src/common/logger.cpp
-@@ -106,6 +106,10 @@ void Logger::setup(bool keepMessages)
+@@ -37,7 +37,27 @@ namespace {
+
+ QByteArray msgWithTime(const Logger::LogEntry& msg)
+ {
+- return (msg.timeStamp.toString("yyyy-MM-dd hh:mm:ss ") + msg.message + "\n").toUtf8();
++ QString levelString;
++
++ switch (msg.logLevel) {
++ case Logger::LogLevel::Debug:
++ levelString = "[Debug] ";
++ break;
++ case Logger::LogLevel::Info:
++ levelString = "[Info ] ";
++ break;
++ case Logger::LogLevel::Warning:
++ levelString = "[Warn ] ";
++ break;
++ case Logger::LogLevel::Error:
++ levelString = "[Error] ";
++ break;
++ case Logger::LogLevel::Fatal:
++ levelString = "[FATAL] ";
++ break;
++ }
++
++ return (msg.timeStamp.toString("yyyy-MM-dd hh:mm:ss ") + levelString + msg.message + "\n").toUtf8();
+ }
+
+ } // namespace
+@@ -106,6 +126,23 @@ void Logger::setup(bool keepMessages)
#ifdef HAVE_SYSLOG
_syslogEnabled = Quassel::isOptionSet("syslog");
+
++ Quassel::RunMode mode = Quassel::runMode();
++ Quassel::BuildInfo info = Quassel::buildInfo();
++ QString prgname = info.applicationName;
++
++ if (mode == Quassel::RunMode::ClientOnly) {
++ prgname = info.clientApplicationName;
++ } else if (mode == Quassel::RunMode::CoreOnly) {
++ prgname = info.coreApplicationName;
++ }
++
++ _prgname = prgname.toLocal8Bit();
++
+ // set up options, program name, and facility for later calls to syslog(3)
-+ if (_syslogEnabled)
-+ openlog("quasselcore", LOG_PID, LOG_USER);
++ if (_syslogEnabled) {
++ openlog(_prgname.constData(), LOG_PID, LOG_USER);
++ }
#endif
_initialized = true;
-@@ -149,22 +153,25 @@ void Logger::handleMessage(LogLevel level, const QString& msg)
- {
- QString logString;
+@@ -147,28 +184,8 @@ void Logger::handleMessage(QtMsgType type, const QString& msg)
+ void Logger::handleMessage(LogLevel level, const QString& msg)
+ {
+- QString logString;
+-
- switch (level) {
- case LogLevel::Debug:
- logString = "[Debug] ";
@@ -42,34 +77,32 @@ index b37abc29c..697d090c1 100644
- case LogLevel::Fatal:
- logString = "[FATAL] ";
- break;
-+ // Only add the log level to the message if we do not output to syslog
-+ if (!_syslogEnabled) {
-+ switch (level) {
-+ case LogLevel::Debug:
-+ logString = "[Debug] ";
-+ break;
-+ case LogLevel::Info:
-+ logString = "[Info ] ";
-+ break;
-+ case LogLevel::Warning:
-+ logString = "[Warn ] ";
-+ break;
-+ case LogLevel::Error:
-+ logString = "[Error] ";
-+ break;
-+ case LogLevel::Fatal:
-+ logString = "[FATAL] ";
-+ break;
-+ }
- }
-
+- }
+-
// Use signal connection to make this method thread-safe
-@@ -208,7 +215,7 @@ void Logger::outputMessage(const LogEntry& message)
+- emit messageLogged({QDateTime::currentDateTime(), level, logString += msg});
++ emit messageLogged({QDateTime::currentDateTime(), level, msg});
+ }
+
+ void Logger::onMessageLogged(const LogEntry& message)
+@@ -208,7 +225,7 @@ void Logger::outputMessage(const LogEntry& message)
case LogLevel::Fatal:
prio = LOG_CRIT;
}
-- syslog(prio|LOG_USER, "%s", qPrintable(message.message));
+- syslog(prio | LOG_USER, "%s", qPrintable(message.message));
+ syslog(prio, "%s", qPrintable(message.message));
}
#endif
+diff --git a/src/common/logger.h b/src/common/logger.h
+index 751fa05f..0f8cf820 100644
+--- a/src/common/logger.h
++++ b/src/common/logger.h
+@@ -111,6 +111,7 @@ private:
+ std::vector<LogEntry> _messages;
+ bool _keepMessages{true};
+ bool _initialized{false};
++ QByteArray _prgname;
+ };
+
+ Q_DECLARE_METATYPE(Logger::LogEntry)