logger: resolve program name using RunMode and BuildInfo
authorWolfgang Müller <vehk@vehk.de>
Wed, 13 Feb 2019 13:48:19 +0000 (14:48 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 14 Feb 2019 21:16:15 +0000 (22:16 +0100)
src/common/logger.cpp
src/common/logger.h

index 031aa5e..d17e182 100644 (file)
@@ -127,9 +127,22 @@ 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;
index 3755abf..7b88078 100644 (file)
@@ -111,6 +111,7 @@ private:
     std::vector<LogEntry> _messages;
     bool _keepMessages{true};
     bool _initialized{false};
+    QByteArray _prgname;
 };
 
 Q_DECLARE_METATYPE(Logger::LogEntry)