X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Flogger.cpp;h=031aa5e0771a81b69621c7f25a8a708a23ba04ea;hp=2c601fdbfedf0a9e5dd82ec77daebb1862919692;hb=366189e4477a971dbe11c180154b36792d2fd38a;hpb=d9026a22f17d5f8b2734cbf0348ad35de5b13f0b diff --git a/src/common/logger.cpp b/src/common/logger.cpp index 2c601fdb..031aa5e0 100644 --- a/src/common/logger.cpp +++ b/src/common/logger.cpp @@ -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 @@ -151,31 +171,8 @@ void Logger::handleMessage(QtMsgType type, const QString& msg) void Logger::handleMessage(LogLevel level, const QString& msg) { - QString logString; - - // 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 - emit messageLogged({QDateTime::currentDateTime(), level, logString += msg}); + emit messageLogged({QDateTime::currentDateTime(), level, msg}); } void Logger::onMessageLogged(const LogEntry& message)