/***************************************************************************
- * Copyright (C) 2005-2019 by the Quassel Project *
+ * Copyright (C) 2005-2020 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
QByteArray msgWithTime(const Logger::LogEntry& msg)
{
- 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();
+ return (msg.toString() + "\n").toUtf8();
}
} // namespace
#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;
}
#endif
}
+
+
+QString Logger::LogEntry::toString() const
+{
+ QString levelString;
+
+ switch (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 timeStamp.toString("yyyy-MM-dd hh:mm:ss ") + levelString + message;
+}