From: Manuel Nickschas Date: Sun, 14 Oct 2018 22:49:57 +0000 (+0200) Subject: modernize: Remove custom Quassel-specific log macros X-Git-Tag: test-travis-01~114 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=8c6448c2e0048389fbac9e2e9daf22b5b050d5b6 modernize: Remove custom Quassel-specific log macros The quInfo(), quWarning(), quError() macros were introduced a long time ago to provide custom log message handling, such as logging to file or syslog. Such features have been directly supported for the standard Qt log macros for a while now, using a global message handler. The only reason for Quassel's custom macros to still exist was the lack of an info log level prior to Qt 5.5. As we can now rely on Qt 5.5 to be available, replace the custom macros by Qt ones, and remove LogMessage which is no longer needed. --- diff --git a/src/client/clientauthhandler.cpp b/src/client/clientauthhandler.cpp index a5bf291b..50485547 100644 --- a/src/client/clientauthhandler.cpp +++ b/src/client/clientauthhandler.cpp @@ -30,7 +30,6 @@ #include "client.h" #include "clientsettings.h" -#include "logmessage.h" #include "peerfactory.h" #include "util.h" @@ -324,10 +323,10 @@ void ClientAuthHandler::onConnectionReady() const auto& coreFeatures = _peer->features(); auto unsupported = coreFeatures.toStringList(false); if (!unsupported.isEmpty()) { - quInfo() << qPrintable(tr("Core does not support the following features: %1").arg(unsupported.join(", "))); + qInfo() << qPrintable(tr("Core does not support the following features: %1").arg(unsupported.join(", "))); } if (!coreFeatures.unknownFeatures().isEmpty()) { - quInfo() << qPrintable(tr("Core supports unknown features: %1").arg(coreFeatures.unknownFeatures().join(", "))); + qInfo() << qPrintable(tr("Core supports unknown features: %1").arg(coreFeatures.unknownFeatures().join(", "))); } emit connectionReady(); diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index e7d72644..351c40c6 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -27,7 +27,6 @@ target_sources(${TARGET} PRIVATE irclisthelper.cpp ircuser.cpp logger.cpp - logmessage.cpp message.cpp messageevent.cpp network.cpp diff --git a/src/common/expressionmatch.cpp b/src/common/expressionmatch.cpp index 17d08a52..73856a38 100644 --- a/src/common/expressionmatch.cpp +++ b/src/common/expressionmatch.cpp @@ -25,8 +25,6 @@ #include #include -#include "logmessage.h" - ExpressionMatch::ExpressionMatch(const QString& expression, MatchMode mode, bool caseSensitive) { // Store the original parameters for later reference @@ -379,7 +377,7 @@ void ExpressionMatch::cacheRegEx() // level as ideally someone's not just going to leave a broken match rule around. For // MatchRegEx, they probably need to fix their regex rule. For the other modes, there's // probably a bug in the parsing routines (which should also be fixed). - quInfo() << "Could not parse expression match rule" << _sourceExpression << "(match mode:" << (int)_sourceMode + qInfo() << "Could not parse expression match rule" << _sourceExpression << "(match mode:" << (int)_sourceMode << "), this rule will be ignored"; } } diff --git a/src/common/logmessage.cpp b/src/common/logmessage.cpp deleted file mode 100644 index 573e61fc..00000000 --- a/src/common/logmessage.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2018 by the Quassel Project * - * devel@quassel-irc.org * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) version 3. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "logmessage.h" - -#include -#include -#include - -#include "quassel.h" - -LogMessage::LogMessage(Logger::LogLevel level) - : _stream(&_buffer, QIODevice::WriteOnly) - , _logLevel(level) -{} - -LogMessage::~LogMessage() -{ - Quassel::instance()->logger()->handleMessage(_logLevel, _buffer); -} - -LogMessage& LogMessage::operator<<(const QStringList& t) -{ - _stream << t.join(" ") << " "; - return *this; -} - -LogMessage& LogMessage::operator<<(bool t) -{ - _stream << (t ? "true" : "false") << " "; - return *this; -} diff --git a/src/common/logmessage.h b/src/common/logmessage.h deleted file mode 100644 index b4795ad7..00000000 --- a/src/common/logmessage.h +++ /dev/null @@ -1,99 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2018 by the Quassel Project * - * devel@quassel-irc.org * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) version 3. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#pragma once - -#include "common-export.h" - -#include -#include - -#include "logger.h" -#include "types.h" - -/** - * Class encapsulating a single log message. - * - * Very similar in concept to qDebug() and friends. - */ -class COMMON_EXPORT LogMessage -{ -public: - LogMessage(Logger::LogLevel level); - ~LogMessage(); - - template - LogMessage& operator<<(const T& value) - { - _stream << value << " "; - return *this; - } - - LogMessage& operator<<(const QStringList& t); - LogMessage& operator<<(bool t); - -private: - QTextStream _stream; - QString _buffer; - Logger::LogLevel _logLevel; -}; - -// The only reason for LogMessage and the helpers below to exist is the fact that Qt versions -// prior to 5.5 did not support the Info level. -// Once we can rely on Qt 5.5, they will be removed and replaced by the native Qt functions. - -/** - * Creates an info-level log message. - * - * @sa qInfo - */ -class quInfo : public LogMessage -{ -public: - quInfo() - : LogMessage(Logger::LogLevel::Info) - {} -}; - -/** - * Creates a warning-level log message. - * - * @sa qWarning - */ -class quWarning : public LogMessage -{ -public: - quWarning() - : LogMessage(Logger::LogLevel::Warning) - {} -}; - -/** - * Creates an error-level log message. - * - * @sa qCritical - */ -class quError : public LogMessage -{ -public: - quError() - : LogMessage(Logger::LogLevel::Error) - {} -}; diff --git a/src/common/posixsignalwatcher.cpp b/src/common/posixsignalwatcher.cpp index eee39183..0b2bfc91 100644 --- a/src/common/posixsignalwatcher.cpp +++ b/src/common/posixsignalwatcher.cpp @@ -32,8 +32,6 @@ #include #include -#include "logmessage.h" - int PosixSignalWatcher::_sockpair[2]; PosixSignalWatcher::PosixSignalWatcher(QObject* parent) @@ -88,7 +86,7 @@ void PosixSignalWatcher::onNotify(int sockfd) int signal; auto bytes = ::read(sockfd, &signal, sizeof(signal)); Q_UNUSED(bytes) - quInfo() << "Caught signal" << signal; + qInfo() << "Caught signal" << signal; switch (signal) { case SIGHUP: diff --git a/src/common/quassel.cpp b/src/common/quassel.cpp index fdcd0527..3268ffeb 100644 --- a/src/common/quassel.cpp +++ b/src/common/quassel.cpp @@ -37,7 +37,6 @@ #include "bufferinfo.h" #include "identity.h" #include "logger.h" -#include "logmessage.h" #include "message.h" #include "network.h" #include "peer.h" @@ -99,7 +98,7 @@ void Quassel::quit() // Protect against multiple invocations (e.g. triggered by MainWin::closeEvent()) if (!_quitting) { _quitting = true; - quInfo() << "Quitting..."; + qInfo() << "Quitting..."; if (_quitHandlers.empty()) { QCoreApplication::quit(); } @@ -291,9 +290,9 @@ void Quassel::handleSignal(AbstractSignalWatcher::Action action) case AbstractSignalWatcher::Action::Reload: // Most applications use this as the 'configuration reload' command, e.g. nginx uses it for graceful reloading of processes. if (!_reloadHandlers.empty()) { - quInfo() << "Reloading configuration"; + qInfo() << "Reloading configuration"; if (reloadConfig()) { - quInfo() << "Successfully reloaded configuration"; + qInfo() << "Successfully reloaded configuration"; } } break; @@ -302,7 +301,7 @@ void Quassel::handleSignal(AbstractSignalWatcher::Action action) quit(); } else { - quInfo() << "Already shutting down, ignoring signal"; + qInfo() << "Already shutting down, ignoring signal"; } break; case AbstractSignalWatcher::Action::HandleCrash: diff --git a/src/common/windowssignalwatcher.cpp b/src/common/windowssignalwatcher.cpp index f31e0383..c68bc8e1 100644 --- a/src/common/windowssignalwatcher.cpp +++ b/src/common/windowssignalwatcher.cpp @@ -25,8 +25,6 @@ #include -#include "logmessage.h" - // This handler is called by Windows in a different thread when a console event happens // FIXME: When the console window is closed, the application is supposedly terminated as soon as // this handler returns. We may want to block and wait for the main thread so set some @@ -66,7 +64,7 @@ WindowsSignalWatcher::WindowsSignalWatcher(QObject* parent) void WindowsSignalWatcher::signalHandler(int signal) { - quInfo() << "Caught signal" << signal; + qInfo() << "Caught signal" << signal; switch (signal) { case SIGINT: diff --git a/src/core/abstractsqlstorage.cpp b/src/core/abstractsqlstorage.cpp index f87ac1d6..e80eb2ce 100644 --- a/src/core/abstractsqlstorage.cpp +++ b/src/core/abstractsqlstorage.cpp @@ -26,7 +26,6 @@ #include #include -#include "logmessage.h" #include "quassel.h" int AbstractSqlStorage::_nextConnectionId = 0; @@ -99,12 +98,12 @@ void AbstractSqlStorage::addConnectionToPool() void AbstractSqlStorage::dbConnect(QSqlDatabase& db) { if (!db.open()) { - quWarning() << "Unable to open database" << displayName() << "for thread" << QThread::currentThread(); - quWarning() << "-" << db.lastError().text(); + qWarning() << "Unable to open database" << displayName() << "for thread" << QThread::currentThread(); + qWarning() << "-" << db.lastError().text(); } else { if (!initDbSession(db)) { - quWarning() << "Unable to initialize database" << displayName() << "for thread" << QThread::currentThread(); + qWarning() << "Unable to initialize database" << displayName() << "for thread" << QThread::currentThread(); db.close(); } } @@ -131,7 +130,7 @@ Storage::State AbstractSqlStorage::init(const QVariantMap& settings, const QProc } if (installedSchemaVersion() < schemaVersion()) { - quInfo() << qPrintable(tr("Installed database schema (version %1) is not up to date. Upgrading to " + qInfo() << qPrintable(tr("Installed database schema (version %1) is not up to date. Upgrading to " "version %2... This may take a while for major upgrades.") .arg(installedSchemaVersion()) .arg(schemaVersion())); @@ -144,10 +143,10 @@ Storage::State AbstractSqlStorage::init(const QVariantMap& settings, const QProc } // Add a message when migration succeeds to avoid confusing folks by implying the schema upgrade failed if // later functionality does not work. - quInfo() << qPrintable(tr("Installed database schema successfully upgraded to version %1.").arg(schemaVersion())); + qInfo() << qPrintable(tr("Installed database schema successfully upgraded to version %1.").arg(schemaVersion())); } - quInfo() << qPrintable(displayName()) << "storage backend is ready. Schema version:" << installedSchemaVersion(); + qInfo() << qPrintable(displayName()) << "storage backend is ready. Schema version:" << installedSchemaVersion(); return IsReady; } diff --git a/src/core/cipher.cpp b/src/core/cipher.cpp index 2d9bff42..efbd88e5 100644 --- a/src/core/cipher.cpp +++ b/src/core/cipher.cpp @@ -14,8 +14,6 @@ #include "cipher.h" -#include "logmessage.h" - Cipher::Cipher() { m_primeNum = QCA::BigInteger( diff --git a/src/core/core.cpp b/src/core/core.cpp index a59d8972..9f9e1c6a 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -28,7 +28,6 @@ #include "coresession.h" #include "coresettings.h" #include "internalpeer.h" -#include "logmessage.h" #include "network.h" #include "postgresqlstorage.h" #include "quassel.h" @@ -185,7 +184,7 @@ void Core::init() throw ExitException{EXIT_FAILURE, tr("Cannot write quasselcore configuration; probably a permission problem.")}; } - quInfo() << "Core is currently not configured! Please connect with a Quassel Client for basic setup."; + qInfo() << "Core is currently not configured! Please connect with a Quassel Client for basic setup."; } } else { @@ -257,7 +256,7 @@ void Core::initAsync() void Core::shutdown() { - quInfo() << "Core shutting down..."; + qInfo() << "Core shutting down..."; saveState(); @@ -281,7 +280,7 @@ void Core::onSessionShutdown(SessionThread* session) { _sessions.take(_sessions.key(session))->deleteLater(); if (_sessions.isEmpty()) { - quInfo() << "Core shutdown complete!"; + qInfo() << "Core shutdown complete!"; emit shutdownComplete(); } } @@ -301,11 +300,11 @@ void Core::saveState() void Core::restoreState() { if (!_configured) { - quWarning() << qPrintable(tr("Cannot restore a state for an unconfigured core!")); + qWarning() << qPrintable(tr("Cannot restore a state for an unconfigured core!")); return; } if (_sessions.count()) { - quWarning() << qPrintable(tr("Calling restoreState() even though active sessions exist!")); + qWarning() << qPrintable(tr("Calling restoreState() even though active sessions exist!")); return; } @@ -313,7 +312,7 @@ void Core::restoreState() /* We don't check, since we are at the first version since switching to Git uint statever = s.coreState().toMap()["CoreStateVersion"].toUInt(); if(statever < 1) { - quWarning() << qPrintable(tr("Core state too old, ignoring...")); + qWarning() << qPrintable(tr("Core state too old, ignoring...")); return; } */ @@ -322,7 +321,7 @@ void Core::restoreState() QVariantList activeSessions = instance()->_storage->getCoreState(activeSessionsFallback); if (activeSessions.count() > 0) { - quInfo() << "Restoring previous core state..."; + qInfo() << "Restoring previous core state..."; for (auto&& v : activeSessions) { UserId user = v.value(); sessionForUser(user, true); @@ -360,7 +359,7 @@ QString Core::setupCore(const QString& adminUser, return tr("Could not setup storage!"); } - quInfo() << "Selected authenticator:" << authenticator; + qInfo() << "Selected authenticator:" << authenticator; if (!(_configured = initAuthenticator(authenticator, authSetupData, {}, false, true))) { return tr("Could not setup authenticator!"); } @@ -376,7 +375,7 @@ QString Core::setupCore(const QString& adminUser, } saveAuthenticatorSettings(authenticator, authSetupData); - quInfo() << qPrintable(tr("Creating admin user...")); + qInfo() << qPrintable(tr("Creating admin user...")); _storage->addUser(adminUser, adminPassword); cacheSysIdent(); startListening(); // TODO check when we need this @@ -430,7 +429,7 @@ bool Core::initStorage( const QString& backend, const QVariantMap& settings, const QProcessEnvironment& environment, bool loadFromEnvironment, bool setup) { if (backend.isEmpty()) { - quWarning() << "No storage backend selected!"; + qWarning() << "No storage backend selected!"; return false; } @@ -525,7 +524,7 @@ bool Core::initAuthenticator( const QString& backend, const QVariantMap& settings, const QProcessEnvironment& environment, bool loadFromEnvironment, bool setup) { if (backend.isEmpty()) { - quWarning() << "No authenticator selected!"; + qWarning() << "No authenticator selected!"; return false; } @@ -636,29 +635,27 @@ bool Core::startListening() switch (addr.protocol()) { case QAbstractSocket::IPv6Protocol: if (_v6server.listen(addr, port)) { - quInfo() << qPrintable(tr("Listening for GUI clients on IPv6 %1 port %2 using protocol version %3") - .arg(addr.toString()) - .arg(_v6server.serverPort()) - .arg(Quassel::buildInfo().protocolVersion)); + qInfo() << qPrintable(tr("Listening for GUI clients on IPv6 %1 port %2 using protocol version %3") + .arg(addr.toString()) + .arg(_v6server.serverPort()) + .arg(Quassel::buildInfo().protocolVersion)); success = true; } else - quWarning() << qPrintable( - tr("Could not open IPv6 interface %1:%2: %3").arg(addr.toString()).arg(port).arg(_v6server.errorString())); + qWarning() << qPrintable(tr("Could not open IPv6 interface %1:%2: %3").arg(addr.toString()).arg(port).arg(_v6server.errorString())); break; case QAbstractSocket::IPv4Protocol: if (_server.listen(addr, port)) { - quInfo() << qPrintable(tr("Listening for GUI clients on IPv4 %1 port %2 using protocol version %3") - .arg(addr.toString()) - .arg(_server.serverPort()) - .arg(Quassel::buildInfo().protocolVersion)); + qInfo() << qPrintable(tr("Listening for GUI clients on IPv4 %1 port %2 using protocol version %3") + .arg(addr.toString()) + .arg(_server.serverPort()) + .arg(Quassel::buildInfo().protocolVersion)); success = true; } else { // if v6 succeeded on Any, the port will be already in use - don't display the error then if (!success || _server.serverError() != QAbstractSocket::AddressInUseError) - quWarning() << qPrintable( - tr("Could not open IPv4 interface %1:%2: %3").arg(addr.toString()).arg(port).arg(_server.errorString())); + qWarning() << qPrintable(tr("Could not open IPv4 interface %1:%2: %3").arg(addr.toString()).arg(port).arg(_server.errorString())); } break; default: @@ -669,7 +666,7 @@ bool Core::startListening() } } if (!success) - quError() << qPrintable(tr("Could not open any network interfaces to listen on!")); + qCritical() << qPrintable(tr("Could not open any network interfaces to listen on!")); if (_identServer) { _identServer->startListening(); @@ -695,9 +692,9 @@ void Core::stopListening(const QString& reason) } if (wasListening) { if (reason.isEmpty()) - quInfo() << "No longer listening for GUI clients."; + qInfo() << "No longer listening for GUI clients."; else - quInfo() << qPrintable(reason); + qInfo() << qPrintable(reason); } } @@ -715,7 +712,7 @@ void Core::incomingConnection() connect(handler, &AuthHandler::socketError, this, &Core::socketError); connect(handler, &CoreAuthHandler::handshakeComplete, this, &Core::setupClientSession); - quInfo() << qPrintable(tr("Client connected from")) << qPrintable(socket->peerAddress().toString()); + qInfo() << qPrintable(tr("Client connected from")) << qPrintable(socket->peerAddress().toString()); if (!_configured) { stopListening(tr("Closing server for basic setup.")); @@ -729,7 +726,7 @@ void Core::clientDisconnected() auto* handler = qobject_cast(sender()); Q_ASSERT(handler); - quInfo() << qPrintable(tr("Non-authed client disconnected:")) << qPrintable(handler->socket()->peerAddress().toString()); + qInfo() << qPrintable(tr("Non-authed client disconnected:")) << qPrintable(handler->socket()->peerAddress().toString()); _connectingClients.remove(handler); handler->deleteLater(); @@ -802,13 +799,13 @@ void Core::setupInternalClientSession(QPointer clientPeer) uid = _storage->internalUser(); } else { - quWarning() << "Core::setupInternalClientSession(): You're trying to run monolithic Quassel with an unusable Backend! Go fix it!"; + qWarning() << "Core::setupInternalClientSession(): You're trying to run monolithic Quassel with an unusable Backend! Go fix it!"; emit exitRequested(EXIT_FAILURE, tr("Cannot setup storage backend.")); return; } if (!clientPeer) { - quWarning() << "Client peer went away, not starting a session"; + qWarning() << "Client peer went away, not starting a session"; return; } @@ -831,7 +828,7 @@ SessionThread* Core::sessionForUser(UserId uid, bool restore) void Core::socketError(QAbstractSocket::SocketError err, const QString& errorString) { - quWarning() << QString("Socket error %1: %2").arg(err).arg(errorString); + qWarning() << QString("Socket error %1: %2").arg(err).arg(errorString); } QVariantList Core::backendInfo() @@ -892,8 +889,8 @@ bool Core::selectBackend(const QString& backend) _registeredStorageBackends.end(), std::back_inserter(backends), [](const DeferredSharedPtr& backend) { return backend->displayName(); }); - quWarning() << qPrintable(tr("Unsupported storage backend: %1").arg(backend)); - quWarning() << qPrintable(tr("Supported backends are:")) << qPrintable(backends.join(", ")); + qWarning() << qPrintable(tr("Unsupported storage backend: %1").arg(backend)); + qWarning() << qPrintable(tr("Supported backends are:")) << qPrintable(backends.join(", ")); return false; } @@ -905,27 +902,27 @@ bool Core::selectBackend(const QString& backend) if (!saveBackendSettings(backend, settings)) { qCritical() << qPrintable(QString("Could not save backend settings, probably a permission problem.")); } - quWarning() << qPrintable(tr("Switched storage backend to: %1").arg(backend)); - quWarning() << qPrintable(tr("Backend already initialized. Skipping Migration...")); + qWarning() << qPrintable(tr("Switched storage backend to: %1").arg(backend)); + qWarning() << qPrintable(tr("Backend already initialized. Skipping Migration...")); return true; case Storage::NotAvailable: qCritical() << qPrintable(tr("Storage backend is not available: %1").arg(backend)); return false; case Storage::NeedsSetup: if (!storage->setup(settings)) { - quWarning() << qPrintable(tr("Unable to setup storage backend: %1").arg(backend)); + qWarning() << qPrintable(tr("Unable to setup storage backend: %1").arg(backend)); return false; } if (storage->init(settings) != Storage::IsReady) { - quWarning() << qPrintable(tr("Unable to initialize storage backend: %1").arg(backend)); + qWarning() << qPrintable(tr("Unable to initialize storage backend: %1").arg(backend)); return false; } if (!saveBackendSettings(backend, settings)) { qCritical() << qPrintable(QString("Could not save backend settings, probably a permission problem.")); } - quWarning() << qPrintable(tr("Switched storage backend to: %1").arg(backend)); + qWarning() << qPrintable(tr("Switched storage backend to: %1").arg(backend)); break; } @@ -945,19 +942,19 @@ bool Core::selectBackend(const QString& backend) } return true; } - quWarning() << qPrintable(tr("Unable to migrate storage backend! (No migration writer for %1)").arg(backend)); + qWarning() << qPrintable(tr("Unable to migrate storage backend! (No migration writer for %1)").arg(backend)); return false; } // inform the user why we cannot merge if (!_storage) { - quWarning() << qPrintable(tr("No currently active storage backend. Skipping migration...")); + qWarning() << qPrintable(tr("No currently active storage backend. Skipping migration...")); } else if (!reader) { - quWarning() << qPrintable(tr("Currently active storage backend does not support migration: %1").arg(_storage->displayName())); + qWarning() << qPrintable(tr("Currently active storage backend does not support migration: %1").arg(_storage->displayName())); } if (writer) { - quWarning() << qPrintable(tr("New storage backend does not support migration: %1").arg(backend)); + qWarning() << qPrintable(tr("New storage backend does not support migration: %1").arg(backend)); } // so we were unable to merge, but let's create a user \o/ @@ -979,8 +976,8 @@ bool Core::selectAuthenticator(const QString& backend) _registeredAuthenticators.end(), std::back_inserter(authenticators), [](const DeferredSharedPtr& authenticator) { return authenticator->displayName(); }); - quWarning() << qPrintable(tr("Unsupported authenticator: %1").arg(backend)); - quWarning() << qPrintable(tr("Supported authenticators are:")) << qPrintable(authenticators.join(", ")); + qWarning() << qPrintable(tr("Unsupported authenticator: %1").arg(backend)); + qWarning() << qPrintable(tr("Supported authenticators are:")) << qPrintable(authenticators.join(", ")); return false; } @@ -990,24 +987,24 @@ bool Core::selectAuthenticator(const QString& backend) switch (state) { case Authenticator::IsReady: saveAuthenticatorSettings(backend, settings); - quWarning() << qPrintable(tr("Switched authenticator to: %1").arg(backend)); + qWarning() << qPrintable(tr("Switched authenticator to: %1").arg(backend)); return true; case Authenticator::NotAvailable: qCritical() << qPrintable(tr("Authenticator is not available: %1").arg(backend)); return false; case Authenticator::NeedsSetup: if (!auther->setup(settings)) { - quWarning() << qPrintable(tr("Unable to setup authenticator: %1").arg(backend)); + qWarning() << qPrintable(tr("Unable to setup authenticator: %1").arg(backend)); return false; } if (auther->init(settings) != Authenticator::IsReady) { - quWarning() << qPrintable(tr("Unable to initialize authenticator: %1").arg(backend)); + qWarning() << qPrintable(tr("Unable to initialize authenticator: %1").arg(backend)); return false; } saveAuthenticatorSettings(backend, settings); - quWarning() << qPrintable(tr("Switched authenticator to: %1").arg(backend)); + qWarning() << qPrintable(tr("Switched authenticator to: %1").arg(backend)); } _authenticator = std::move(auther); @@ -1035,11 +1032,11 @@ bool Core::createUser() enableStdInEcho(); if (password != password2) { - quWarning() << "Passwords don't match!"; + qWarning() << "Passwords don't match!"; return false; } if (password.isEmpty()) { - quWarning() << "Password is empty!"; + qWarning() << "Password is empty!"; return false; } @@ -1048,7 +1045,7 @@ bool Core::createUser() return true; } else { - quWarning() << "Unable to add user:" << qPrintable(username); + qWarning() << "Unable to add user:" << qPrintable(username); return false; } } @@ -1082,11 +1079,11 @@ bool Core::changeUserPass(const QString& username) enableStdInEcho(); if (password != password2) { - quWarning() << "Passwords don't match!"; + qWarning() << "Passwords don't match!"; return false; } if (password.isEmpty()) { - quWarning() << "Password is empty!"; + qWarning() << "Password is empty!"; return false; } @@ -1095,7 +1092,7 @@ bool Core::changeUserPass(const QString& username) return true; } else { - quWarning() << "Failed to change password!"; + qWarning() << "Failed to change password!"; return false; } } diff --git a/src/core/coreauthhandler.cpp b/src/core/coreauthhandler.cpp index d559e44e..3514ecd1 100644 --- a/src/core/coreauthhandler.cpp +++ b/src/core/coreauthhandler.cpp @@ -25,7 +25,6 @@ #endif #include "core.h" -#include "logmessage.h" using namespace Protocol; @@ -167,7 +166,7 @@ void CoreAuthHandler::handle(const RegisterClient& msg) useSsl = _connectionFeatures & Protocol::Encryption; if (Quassel::isOptionSet("require-ssl") && !useSsl && !_peer->isLocal()) { - quInfo() << qPrintable(tr("SSL required but non-SSL connection attempt from %1").arg(socket()->peerAddress().toString())); + qInfo() << qPrintable(tr("SSL required but non-SSL connection attempt from %1").arg(socket()->peerAddress().toString())); _peer->dispatch(ClientDenied(tr("SSL is required!
You need to use SSL in order to connect to this core."))); _peer->close(); return; @@ -204,7 +203,7 @@ void CoreAuthHandler::handle(const SetupData& msg) // The default parameter to authenticator is Database. // Maybe this should be hardcoded elsewhere, i.e. as a define. QString authenticator = msg.authenticator; - quInfo() << "[" << authenticator << "]"; + qInfo() << "[" << authenticator << "]"; if (authenticator.trimmed().isEmpty()) { authenticator = QString("Database"); } @@ -237,27 +236,27 @@ void CoreAuthHandler::handle(const Login& msg) } if (uid == 0) { - quInfo() << qPrintable(tr("Invalid login attempt from %1 as \"%2\"").arg(socket()->peerAddress().toString(), msg.user)); + qInfo() << qPrintable(tr("Invalid login attempt from %1 as \"%2\"").arg(socket()->peerAddress().toString(), msg.user)); _peer->dispatch(LoginFailed(tr( "Invalid username or password!
The username/password combination you supplied could not be found in the database."))); return; } _peer->dispatch(LoginSuccess()); - quInfo() << qPrintable(tr("Client %1 initialized and authenticated successfully as \"%2\" (UserId: %3).") - .arg(socket()->peerAddress().toString(), msg.user, QString::number(uid.toInt()))); + qInfo() << qPrintable(tr("Client %1 initialized and authenticated successfully as \"%2\" (UserId: %3).") + .arg(socket()->peerAddress().toString(), msg.user, QString::number(uid.toInt()))); const auto& clientFeatures = _peer->features(); auto unsupported = clientFeatures.toStringList(false); if (!unsupported.isEmpty()) { if (unsupported.contains("NoFeatures")) - quInfo() << qPrintable(tr("Client does not support extended features.")); + qInfo() << qPrintable(tr("Client does not support extended features.")); else - quInfo() << qPrintable(tr("Client does not support the following features: %1").arg(unsupported.join(", "))); + qInfo() << qPrintable(tr("Client does not support the following features: %1").arg(unsupported.join(", "))); } if (!clientFeatures.unknownFeatures().isEmpty()) { - quInfo() << qPrintable(tr("Client supports unknown features: %1").arg(clientFeatures.unknownFeatures().join(", "))); + qInfo() << qPrintable(tr("Client supports unknown features: %1").arg(clientFeatures.unknownFeatures().join(", "))); } disconnect(socket(), nullptr, this, nullptr); diff --git a/src/core/corebasichandler.cpp b/src/core/corebasichandler.cpp index 38b510e5..aa4c4428 100644 --- a/src/core/corebasichandler.cpp +++ b/src/core/corebasichandler.cpp @@ -20,7 +20,6 @@ #include "corebasichandler.h" -#include "logmessage.h" #include "util.h" CoreBasicHandler::CoreBasicHandler(CoreNetwork* parent) diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index b5de50ed..3bab9d9d 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -44,7 +44,6 @@ #include "ircchannel.h" #include "ircparser.h" #include "ircuser.h" -#include "logmessage.h" #include "messageevent.h" #include "remotepeer.h" #include "storage.h" @@ -272,7 +271,7 @@ void CoreSession::removeClient(Peer* peer) { auto* p = qobject_cast(peer); if (p) - quInfo() << qPrintable(tr("Client")) << p->description() << qPrintable(tr("disconnected (UserId: %1).").arg(user().toInt())); + qInfo() << qPrintable(tr("Client")) << p->description() << qPrintable(tr("disconnected (UserId: %1).").arg(user().toInt())); _coreInfo->setConnectedClientData(signalProxy()->peerCount(), signalProxy()->peerData()); } diff --git a/src/core/coresessioneventprocessor.cpp b/src/core/coresessioneventprocessor.cpp index df4a4091..f9f54f3b 100644 --- a/src/core/coresessioneventprocessor.cpp +++ b/src/core/coresessioneventprocessor.cpp @@ -28,7 +28,6 @@ #include "ctcpevent.h" #include "ircevent.h" #include "ircuser.h" -#include "logmessage.h" #include "messageevent.h" #include "netsplit.h" #include "quassel.h" @@ -1548,7 +1547,7 @@ void CoreSessionEventProcessor::handleCtcpDcc(CtcpEvent* e) { // DCC support is unfinished, experimental and potentially dangerous, so make it opt-in if (!Quassel::isOptionSet("enable-experimental-dcc")) { - quInfo() << "DCC disabled, start core with --enable-experimental-dcc if you really want to try it out"; + qInfo() << "DCC disabled, start core with --enable-experimental-dcc if you really want to try it out"; return; } diff --git a/src/core/identserver.cpp b/src/core/identserver.cpp index bd81e163..5cbb188e 100644 --- a/src/core/identserver.cpp +++ b/src/core/identserver.cpp @@ -23,7 +23,6 @@ #include #include "corenetwork.h" -#include "logmessage.h" IdentServer::IdentServer(QObject* parent) : QObject(parent) @@ -38,19 +37,19 @@ bool IdentServer::startListening() bool success = false; if (_v6server.listen(QHostAddress("::1"), port)) { - quInfo() << qPrintable(tr("Listening for identd clients on IPv6 %1 port %2").arg("::1").arg(_v6server.serverPort())); + qInfo() << qPrintable(tr("Listening for identd clients on IPv6 %1 port %2").arg("::1").arg(_v6server.serverPort())); success = true; } if (_server.listen(QHostAddress("127.0.0.1"), port)) { - quInfo() << qPrintable(tr("Listening for identd clients on IPv4 %1 port %2").arg("127.0.0.1").arg(_server.serverPort())); + qInfo() << qPrintable(tr("Listening for identd clients on IPv4 %1 port %2").arg("127.0.0.1").arg(_server.serverPort())); success = true; } if (!success) { - quError() << qPrintable(tr("Identd could not open any network interfaces to listen on! No identd functionality will be available")); + qWarning() << qPrintable(tr("Identd could not open any network interfaces to listen on! No identd functionality will be available")); } return success; @@ -71,9 +70,9 @@ void IdentServer::stopListening(const QString& msg) if (wasListening) { if (msg.isEmpty()) - quInfo() << "No longer listening for identd clients."; + qInfo() << "No longer listening for identd clients."; else - quInfo() << qPrintable(msg); + qInfo() << qPrintable(msg); } } diff --git a/src/core/ldapauthenticator.cpp b/src/core/ldapauthenticator.cpp index 31221fd7..e7dc3c0c 100644 --- a/src/core/ldapauthenticator.cpp +++ b/src/core/ldapauthenticator.cpp @@ -28,7 +28,6 @@ #include "ldapauthenticator.h" -#include "logmessage.h" #include "network.h" #include "quassel.h" @@ -152,11 +151,11 @@ Authenticator::State LdapAuthenticator::init(const QVariantMap& settings, const bool status = ldapConnect(); if (!status) { - quInfo() << qPrintable(backendId()) << "authenticator cannot connect."; + qInfo() << qPrintable(backendId()) << "authenticator cannot connect."; return NotAvailable; } - quInfo() << qPrintable(backendId()) << "authenticator is ready."; + qInfo() << qPrintable(backendId()) << "authenticator is ready."; return IsReady; } @@ -177,7 +176,7 @@ bool LdapAuthenticator::ldapConnect() serverURIArray = serverURI.toLocal8Bit(); res = ldap_initialize(&_connection, serverURIArray); - quInfo() << "LDAP: Connecting to" << serverURI; + qInfo() << "LDAP: Connecting to" << serverURI; if (res != LDAP_SUCCESS) { qWarning() << "Could not connect to LDAP server:" << ldap_err2string(res); diff --git a/src/core/postgresqlstorage.cpp b/src/core/postgresqlstorage.cpp index 200fd14c..8b12396a 100644 --- a/src/core/postgresqlstorage.cpp +++ b/src/core/postgresqlstorage.cpp @@ -22,7 +22,6 @@ #include -#include "logmessage.h" #include "network.h" #include "quassel.h" @@ -46,7 +45,7 @@ std::unique_ptr PostgreSqlStorage::createMigrationWr bool PostgreSqlStorage::isAvailable() const { if (!QSqlDatabase::isDriverAvailable("QPSQL")) { - quWarning() << qPrintable(tr("PostgreSQL driver plugin not available for Qt. Installed drivers:")) + qWarning() << qPrintable(tr("PostgreSQL driver plugin not available for Qt. Installed drivers:")) << qPrintable(QSqlDatabase::drivers().join(", ")); return false; } @@ -92,7 +91,7 @@ bool PostgreSqlStorage::initDbSession(QSqlDatabase& db) // as this is the expected behavior. // If it is a newer version, switch to legacy mode. - quWarning() << "Switching Postgres to legacy mode. (set standard conforming strings to off)"; + qWarning() << "Switching Postgres to legacy mode. (set standard conforming strings to off)"; // If the following calls fail, it is a legacy DB anyways, so it doesn't matter // and no need to check the outcome. db.exec("set standard_conforming_strings = off"); @@ -106,14 +105,14 @@ bool PostgreSqlStorage::initDbSession(QSqlDatabase& db) if (query.lastError().isValid()) { // We cannot enable standard conforming strings... // since Quassel does no escaping by itself, this would yield a major vulnerability. - quError() << "Failed to enable standard_conforming_strings for the Postgres db!"; + qCritical() << "Failed to enable standard_conforming_strings for the Postgres db!"; return false; } } break; default: // The slash got replaced with 0 or more than 2 slashes! o_O - quError() << "Your version of Qt does something _VERY_ strange to slashes in QSqlQueries! You should consult your trusted doctor!"; + qCritical() << "Your version of Qt does something _VERY_ strange to slashes in QSqlQueries! You should consult your trusted doctor!"; return false; break; } @@ -121,7 +120,7 @@ bool PostgreSqlStorage::initDbSession(QSqlDatabase& db) // Set the PostgreSQL session timezone to UTC, since we want timestamps stored in UTC QSqlQuery tzQuery = db.exec("SET timezone = 'UTC'"); if (tzQuery.lastError().isValid()) { - quError() << "Failed to set timezone to UTC!"; + qCritical() << "Failed to set timezone to UTC!"; return false; } diff --git a/src/core/sqlauthenticator.cpp b/src/core/sqlauthenticator.cpp index 94c759c4..a385254a 100644 --- a/src/core/sqlauthenticator.cpp +++ b/src/core/sqlauthenticator.cpp @@ -21,7 +21,6 @@ #include "sqlauthenticator.h" #include "core.h" -#include "logmessage.h" #include "network.h" #include "quassel.h" @@ -76,6 +75,6 @@ Authenticator::State SqlAuthenticator::init(const QVariantMap& settings, const Q // TODO: FIXME: this should check if the storage provider is ready, but I don't // know if there's an exposed way to do that at the moment. - quInfo() << qPrintable(backendId()) << "authenticator is ready."; + qInfo() << qPrintable(backendId()) << "authenticator is ready."; return IsReady; } diff --git a/src/core/sqlitestorage.cpp b/src/core/sqlitestorage.cpp index 2d06421e..d12262e2 100644 --- a/src/core/sqlitestorage.cpp +++ b/src/core/sqlitestorage.cpp @@ -22,7 +22,6 @@ #include -#include "logmessage.h" #include "network.h" #include "quassel.h" diff --git a/src/core/sslserver.cpp b/src/core/sslserver.cpp index c076a5fe..d3b60703 100644 --- a/src/core/sslserver.cpp +++ b/src/core/sslserver.cpp @@ -26,7 +26,6 @@ #include -#include "logmessage.h" #include "quassel.h" #ifdef HAVE_SSL @@ -54,9 +53,9 @@ SslServer::SslServer(QObject* parent) // Initialize the certificates for first-time usage if (!loadCerts()) { if (!sslWarningShown) { - quWarning() << "SslServer: Unable to set certificate file\n" - << " Quassel Core will still work, but cannot provide SSL for client connections.\n" - << " Please see https://quassel-irc.org/faq/cert to learn how to enable SSL support."; + qWarning() << "SslServer: Unable to set certificate file\n" + << " Quassel Core will still work, but cannot provide SSL for client connections.\n" + << " Please see https://quassel-irc.org/faq/cert to learn how to enable SSL support."; sslWarningShown = true; } } @@ -102,14 +101,14 @@ bool SslServer::reloadCerts() // Reloading certificates currently only occur in response to a request. Always print an // error if something goes wrong, in order to simplify checking if it's working. if (isCertValid()) { - quWarning() << "SslServer: Unable to reload certificate file, reverting\n" - << " Quassel Core will use the previous key to provide SSL for client connections.\n" - << " Please see https://quassel-irc.org/faq/cert to learn how to enable SSL support."; + qWarning() << "SslServer: Unable to reload certificate file, reverting\n" + << " Quassel Core will use the previous key to provide SSL for client connections.\n" + << " Please see https://quassel-irc.org/faq/cert to learn how to enable SSL support."; } else { - quWarning() << "SslServer: Unable to reload certificate file\n" - << " Quassel Core will still work, but cannot provide SSL for client connections.\n" - << " Please see https://quassel-irc.org/faq/cert to learn how to enable SSL support."; + qWarning() << "SslServer: Unable to reload certificate file\n" + << " Quassel Core will still work, but cannot provide SSL for client connections.\n" + << " Please see https://quassel-irc.org/faq/cert to learn how to enable SSL support."; } return false; } @@ -129,19 +128,19 @@ bool SslServer::setCertificate(const QString& path, const QString& keyPath) QFile certFile(path); if (!certFile.exists()) { - quWarning() << "SslServer: Certificate file" << qPrintable(path) << "does not exist"; + qWarning() << "SslServer: Certificate file" << qPrintable(path) << "does not exist"; return false; } if (!certFile.open(QIODevice::ReadOnly)) { - quWarning() << "SslServer: Failed to open certificate file" << qPrintable(path) << "error:" << certFile.error(); + qWarning() << "SslServer: Failed to open certificate file" << qPrintable(path) << "error:" << certFile.error(); return false; } QList certList = QSslCertificate::fromDevice(&certFile); if (certList.isEmpty()) { - quWarning() << "SslServer: Certificate file doesn't contain a certificate"; + qWarning() << "SslServer: Certificate file doesn't contain a certificate"; return false; } @@ -152,7 +151,7 @@ bool SslServer::setCertificate(const QString& path, const QString& keyPath) untestedCA = certList; if (!certFile.reset()) { - quWarning() << "SslServer: IO error reading certificate file"; + qWarning() << "SslServer: IO error reading certificate file"; return false; } @@ -160,12 +159,12 @@ bool SslServer::setCertificate(const QString& path, const QString& keyPath) if (path != keyPath) { QFile keyFile(keyPath); if (!keyFile.exists()) { - quWarning() << "SslServer: Key file" << qPrintable(keyPath) << "does not exist"; + qWarning() << "SslServer: Key file" << qPrintable(keyPath) << "does not exist"; return false; } if (!keyFile.open(QIODevice::ReadOnly)) { - quWarning() << "SslServer: Failed to open key file" << qPrintable(keyPath) << "error:" << keyFile.error(); + qWarning() << "SslServer: Failed to open key file" << qPrintable(keyPath) << "error:" << keyFile.error(); return false; } @@ -179,24 +178,24 @@ bool SslServer::setCertificate(const QString& path, const QString& keyPath) certFile.close(); if (untestedCert.isNull()) { - quWarning() << "SslServer:" << qPrintable(path) << "contains no certificate data"; + qWarning() << "SslServer:" << qPrintable(path) << "contains no certificate data"; return false; } // We allow the core to offer SSL anyway, so no "return false" here. Client will warn about the cert being invalid. const QDateTime now = QDateTime::currentDateTime(); if (now < untestedCert.effectiveDate()) { - quWarning() << "SslServer: Certificate won't be valid before" << untestedCert.effectiveDate().toString(); + qWarning() << "SslServer: Certificate won't be valid before" << untestedCert.effectiveDate().toString(); } else if (now > untestedCert.expiryDate()) { - quWarning() << "SslServer: Certificate expired on" << untestedCert.expiryDate().toString(); + qWarning() << "SslServer: Certificate expired on" << untestedCert.expiryDate().toString(); } else if (untestedCert.isBlacklisted()) { - quWarning() << "SslServer: Certificate blacklisted"; + qWarning() << "SslServer: Certificate blacklisted"; } if (untestedKey.isNull()) { - quWarning() << "SslServer:" << qPrintable(keyPath) << "contains no key data"; + qWarning() << "SslServer:" << qPrintable(keyPath) << "contains no key data"; return false; } @@ -216,7 +215,7 @@ QSslKey SslServer::loadKey(QFile* keyFile) key = QSslKey(keyFile, QSsl::Rsa); if (key.isNull()) { if (!keyFile->reset()) { - quWarning() << "SslServer: IO error reading key file"; + qWarning() << "SslServer: IO error reading key file"; return key; } key = QSslKey(keyFile, QSsl::Ec); diff --git a/src/main/monoapplication.cpp b/src/main/monoapplication.cpp index beee2cd8..1cc07a46 100644 --- a/src/main/monoapplication.cpp +++ b/src/main/monoapplication.cpp @@ -24,7 +24,6 @@ #include "core.h" #include "coreapplication.h" #include "internalpeer.h" -#include "logmessage.h" #include "qtui.h" class InternalPeer; @@ -50,7 +49,7 @@ void MonolithicApplication::init() Quassel::QuitHandler MonolithicApplication::quitHandler() { return [this]() { - quInfo() << "Client shutting down..."; + qInfo() << "Client shutting down..."; connect(_client.get(), &QObject::destroyed, this, &MonolithicApplication::onClientDestroyed); _client.release()->deleteLater(); }; diff --git a/src/qtui/qtuiapplication.cpp b/src/qtui/qtuiapplication.cpp index 11ee358e..cd5d98ac 100644 --- a/src/qtui/qtuiapplication.cpp +++ b/src/qtui/qtuiapplication.cpp @@ -25,7 +25,6 @@ #include #include "chatviewsettings.h" -#include "logmessage.h" #include "mainwin.h" #include "qtui.h" #include "qtuisettings.h" @@ -65,7 +64,7 @@ Quassel::QuitHandler QtUiApplication::quitHandler() { // Wait until the Client instance is destroyed before quitting the event loop return [this]() { - quInfo() << "Client shutting down..."; + qInfo() << "Client shutting down..."; connect(_client.get(), &QObject::destroyed, QCoreApplication::instance(), &QCoreApplication::quit); _client.release()->deleteLater(); };