X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Flogger.cpp;h=51f1366a24f7704a3e7dccaef82d1ace803121e8;hb=fad08c0bc53514b43fdf44e5a792a019b1414367;hp=031aa5e0771a81b69621c7f25a8a708a23ba04ea;hpb=366189e4477a971dbe11c180154b36792d2fd38a;p=quassel.git diff --git a/src/common/logger.cpp b/src/common/logger.cpp index 031aa5e0..51f1366a 100644 --- a/src/common/logger.cpp +++ b/src/common/logger.cpp @@ -37,27 +37,7 @@ namespace { 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 @@ -127,9 +107,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; @@ -231,3 +224,29 @@ void Logger::outputMessage(const LogEntry& message) } #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; +}