Activate logging for quasselcore.
authorSebastian Goth <seezer@roath.org>
Thu, 24 Jul 2008 18:45:01 +0000 (20:45 +0200)
committerSebastian Goth <seezer@roath.org>
Wed, 30 Jul 2008 09:25:00 +0000 (11:25 +0200)
src/common/main.cpp
src/core/abstractsqlstorage.cpp
src/core/basichandler.cpp
src/core/core.cpp
src/core/corenetwork.cpp
src/core/coresession.cpp
src/core/ircserverhandler.cpp
src/core/networkconnection.cpp
src/core/sqlitestorage.cpp
src/core/sslserver.cpp

index d7cd4e5..e72166d 100644 (file)
@@ -22,6 +22,7 @@
 #include <QString>
 #include <QTimer>
 #include <QTranslator>
+#include <QFile>
 
 #include "global.h"
 #include "logger.h"
@@ -64,8 +65,6 @@ int main(int argc, char **argv) {
   signal(SIGTERM, handle_signal);
   signal(SIGINT, handle_signal);
 
-  // Logger logger;
-
   Global::registerMetaTypes();
   Global::setupVersion();
 
@@ -86,6 +85,8 @@ int main(int argc, char **argv) {
 // put core-only arguments here
   Global::parser.addOption("port",'p',"The port quasselcore will listen at",QString("4242"));
   Global::parser.addSwitch("norestore", 'n', "Don't restore last core's state");
+  Global::parser.addOption("logfile",'l',"Path to logfile","./quassel.log");
+  Global::parser.addOption("loglevel",'L',"Loglevel Debug|Info|Warning|Error","Info");
 #endif // BUILD_QTUI
 #ifndef BUILD_CORE
 // put client-only arguments here
@@ -101,6 +102,21 @@ int main(int argc, char **argv) {
     return 1;
   }
 
+  /*
+   This is an initial check if logfile is writable since the warning would spam stdout if done
+   in current Logger implementation. Can be dropped whenever the logfile is only opened once.
+  */
+  if(Global::runMode != Global::ClientOnly) {
+    QFile logFile;
+    if(!Global::parser.value("logfile").isEmpty()) {
+      logFile.setFileName(Global::parser.value("logfile"));
+      if(!logFile.open(QIODevice::Append | QIODevice::Text))
+        qWarning("Warning: Couldn't open logfile '%s' - will log to stdout instead",qPrintable(logFile.fileName()));
+      logFile.close();
+    }
+    else qWarning("Warning: Couldn't open logfile '%s' - will log to stdout instead",qPrintable(logFile.fileName()));
+  }
+
   qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
 
   // Set up i18n support
index b20d1dc..d5cfe63 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "abstractsqlstorage.h"
 
+#include "logger.h"
+
 #include <QSqlError>
 #include <QSqlQuery>
 
@@ -50,8 +52,8 @@ QSqlDatabase AbstractSqlStorage::logDb() {
     return db;
 
   if(!openDb()) {
-    qWarning() << "Unable to Open Database" << displayName();
-    qWarning() << " -" << db.lastError().text();
+    quWarning() << "Unable to Open Database " << displayName();
+    quWarning() << " - " << db.lastError().text();
   }
 
   return QSqlDatabase::database("quassel_connection");
@@ -83,22 +85,22 @@ bool AbstractSqlStorage::init(const QVariantMap &settings) {
     return false;
 
   if(installedSchemaVersion() == -1) {
-    qDebug() << "Storage Schema is missing!";
+    quError() << "Storage Schema is missing!";
     return false;
   }
 
   if(installedSchemaVersion() > schemaVersion()) {
-    qWarning() << "Installed Schema is newer then any known Version.";
+    quError() << "Installed Schema is newer then any known Version.";
     return false;
   }
   
   if(installedSchemaVersion() < schemaVersion()) {
-    qWarning() << "Installed Schema is not up to date. Upgrading...";
+    quWarning() << "Installed Schema is not up to date. Upgrading...";
     if(!upgradeDb())
       return false;
   }
   
-  qDebug() << "Storage Backend is ready. Quassel Schema Version:" << installedSchemaVersion();
+  quInfo() << "Storage Backend is ready. Quassel Schema Version: " << installedSchemaVersion();
   return true;
 }
 
@@ -118,7 +120,7 @@ QString AbstractSqlStorage::queryString(const QString &queryName, int version) {
     
   QFileInfo queryInfo(QString(":/SQL/%1/%2/%3.sql").arg(displayName()).arg(version).arg(queryName));
   if(!queryInfo.exists() || !queryInfo.isFile() || !queryInfo.isReadable()) {
-    qWarning() << "Unable to read SQL-Query" << queryName << "for engine" << displayName();
+    quError() << "Unable to read SQL-Query " << queryName << " for engine " << displayName();
     return QString();
   }
 
@@ -162,14 +164,14 @@ bool AbstractSqlStorage::setup(const QVariantMap &settings) {
   Q_UNUSED(settings)
   QSqlDatabase db = logDb();
   if(!db.isOpen()) {
-    qWarning() << "Unable to setup Logging Backend!";
+    quError() << "Unable to setup Logging Backend!";
     return false;
   }
 
   foreach(QString queryString, setupQueries()) {
     QSqlQuery query = db.exec(queryString);
     if(!watchQuery(&query)) {
-      qWarning() << "Unable to setup Logging Backend!";
+      quError() << "Unable to setup Logging Backend!";
       return false;
     }
   }
@@ -195,7 +197,7 @@ bool AbstractSqlStorage::upgradeDb() {
     foreach(QString queryString, upgradeQueries(ver)) {
       QSqlQuery query = db.exec(queryString);
       if(!watchQuery(&query)) {
-       qWarning() << "Unable to upgrade Logging Backend!";
+       quError() << "Unable to upgrade Logging Backend!";
        return false;
       }
     }
@@ -229,14 +231,17 @@ int AbstractSqlStorage::schemaVersion() {
 
 bool AbstractSqlStorage::watchQuery(QSqlQuery *query) {
   if(query->lastError().isValid()) {
-    qWarning() << "unhandled Error in QSqlQuery!";
-    qWarning() << "                  last Query:\n" << query->lastQuery();
-    qWarning() << "              executed Query:\n" << query->executedQuery();
-    qWarning() << "                bound Values:"   << query->boundValues();
-    qWarning() << "                Error Number:"   << query->lastError().number();
-    qWarning() << "               Error Message:"   << query->lastError().text();
-    qWarning() << "              Driver Message:"   << query->lastError().driverText();
-    qWarning() << "                  DB Message:"   << query->lastError().databaseText();
+    quError() << "unhandled Error in QSqlQuery!";
+    quError() << "                  last Query:\n" << query->lastQuery();
+    quError() << "              executed Query:\n" << query->executedQuery();
+    quError() << "                bound Values: ";
+    QList<QVariant> list = query->boundValues().values();
+    for (int i = 0; i < list.size(); ++i)
+      quError() << i << ": " << list.at(i).toString().toAscii().data();
+    quError() << "                Error Number: "   << query->lastError().number();
+    quError() << "               Error Message: "   << query->lastError().text();
+    quError() << "              Driver Message: "   << query->lastError().driverText();
+    quError() << "                  DB Message: "   << query->lastError().databaseText();
     
     return false;
   }
index a6af537..8b9fd03 100644 (file)
@@ -22,6 +22,7 @@
 #include <QMetaMethod>
 
 #include "util.h"
+#include "logger.h"
 
 BasicHandler::BasicHandler(NetworkConnection *parent)
   : QObject(parent),
@@ -77,7 +78,7 @@ void BasicHandler::handle(const QString &member, QGenericArgument val0,
 
   if(!handlerHash().contains(handler)) {
     if(defaultHandler == -1) {
-      qWarning() << QString("No such Handler: %1::handle%2").arg(metaObject()->className(), handler);
+      quWarning() << QString("No such Handler: %1::handle%2").arg(metaObject()->className(), handler);
       return;
     } else {
       void *param[] = {0, Q_ARG(QString, member).data(), val0.data(), val1.data(), val2.data(), val3.data(), val4.data(),
index 901b0a3..6efa622 100644 (file)
@@ -29,6 +29,7 @@
 #include "signalproxy.h"
 #include "sqlitestorage.h"
 #include "network.h"
+#include "logger.h"
 
 #include "util.h"
 
@@ -54,8 +55,8 @@ Core::Core() : storage(0) {
   registerStorageBackend(new SqliteStorage(this));
 
   if(!_storageBackends.count()) {
-    qWarning() << qPrintable(tr("Could not initialize any storage backend! Exiting..."));
-    qWarning() << qPrintable(tr("Currently, Quassel only supports SQLite3. You need to build your\n"
+    quWarning() << qPrintable(tr("Could not initialize any storage backend! Exiting..."));
+    quWarning() << qPrintable(tr("Currently, Quassel only supports SQLite3. You need to build your\n"
                                 "Qt library with the sqlite plugin enabled in order for quasselcore\n"
                                 "to work."));
     exit(1); // TODO make this less brutal (especially for mono client -> popup)
@@ -70,7 +71,7 @@ void Core::init() {
   CoreSettings cs;
 
   if(!(configured = initStorage(cs.storageSettings().toMap()))) {
-    qWarning("Core is currently not configured! Please connect with a Quassel Client for basic setup.");
+    quWarning() << "Core is currently not configured! Please connect with a Quassel Client for basic setup.";
 
     // try to migrate old settings
     QVariantMap old = cs.oldDbSettings().toMap();
@@ -78,7 +79,7 @@ void Core::init() {
       QVariantMap newSettings;
       newSettings["Backend"] = "SQLite";
       if((configured = initStorage(newSettings))) {
-        qWarning("...but thankfully I found some old settings to migrate!");
+        quWarning() << "...but thankfully I found some old settings to migrate!";
         cs.setStorageSettings(newSettings);
       }
     }
@@ -114,7 +115,7 @@ void Core::restoreState() {
     return;
   }
   if(instance()->sessions.count()) {
-    qWarning() << qPrintable(tr("Calling restoreState() even though active sessions exist!"));
+    quWarning() << qPrintable(tr("Calling restoreState() even though active sessions exist!"));
     return;
   }
   CoreSettings s;
@@ -127,7 +128,7 @@ void Core::restoreState() {
   */
   QVariantList activeSessions = s.coreState().toMap()["ActiveSessions"].toList();
   if(activeSessions.count() > 0) {
-    qDebug() << "Restoring previous core state...";
+    quInfo() << "Restoring previous core state...";
     foreach(QVariant v, activeSessions) {
       UserId user = v.value<UserId>();
       instance()->createSession(user, true);
@@ -149,7 +150,7 @@ QString Core::setupCore(const QVariant &setupData_) {
   }
   CoreSettings s;
   s.setStorageSettings(setupData);
-  qDebug() << qPrintable(tr("Creating admin user..."));
+  quInfo() << qPrintable(tr("Creating admin user..."));
   mutex.lock();
   storage->addUser(user, password);
   mutex.unlock();
@@ -186,12 +187,12 @@ bool Core::initStorage(QVariantMap dbSettings, bool setup) {
   if(_storageBackends.contains(backend)) {
     storage = _storageBackends[backend];
   } else {
-    qWarning() << "Selected storage backend is not available:" << backend;
+    quError() << "Selected storage backend is not available:" << backend;
     return configured = false;
   }
   if(!storage->init(dbSettings)) {
     if(!setup || !(storage->setup(dbSettings) && storage->init(dbSettings))) {
-      qWarning() << "Could not init storage!";
+      quError() << "Could not init storage!";
       storage = 0;
       return configured = false;
     }
@@ -351,9 +352,9 @@ bool Core::startListening(uint port) {
   }
 
   if(!success) {
-    qWarning("%s", qPrintable(QString("Could not open GUI client port %1: %2").arg(port).arg(server.errorString())));
+    quError() << qPrintable(QString("Could not open GUI client port %1: %2").arg(port).arg(server.errorString()));
   } else {
-    qDebug() << "Listening for GUI clients on port" << server.serverPort() << "using protocol version" << Global::protocolVersion;
+    quInfo() << "Listening for GUI clients on port " << server.serverPort() << " using protocol version " << Global::protocolVersion;
   }
   
   return success;
@@ -361,7 +362,7 @@ bool Core::startListening(uint port) {
 
 void Core::stopListening() {
   server.close();
-  qDebug() << "No longer listening for GUI clients.";
+  quInfo() << "No longer listening for GUI clients.";
 }
 
 void Core::incomingConnection() {
@@ -373,11 +374,11 @@ void Core::incomingConnection() {
     
     QVariantMap clientInfo;
     blocksizes.insert(socket, (quint32)0);
-    qDebug() << qPrintable(tr("Client connected from"))  << qPrintable(socket->peerAddress().toString());
+    quInfo() << qPrintable(tr("Client connected from "))  << qPrintable(socket->peerAddress().toString());
 
     if (!configured) {
       server.close();
-      qDebug() << "Closing server for basic setup.";
+      quDebug() << "Closing server for basic setup.";
     }
   }
 }
@@ -396,7 +397,7 @@ void Core::clientHasData() {
 void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) {
   if(!msg.contains("MsgType")) {
     // Client is way too old, does not even use the current init format
-    qWarning() << qPrintable(tr("Antique client trying to connect... refusing."));
+    quWarning() << qPrintable(tr("Antique client trying to connect... refusing."));
     socket->close();
     return;
   }
@@ -414,7 +415,7 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) {
       "This core needs at least client/core protocol version %1.<br>"
       "Please consider upgrading your client.").arg(Global::coreNeedsProtocol);
       SignalProxy::writeDataToDevice(socket, reply);
-      qWarning() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("too old, rejecting."));
+      quWarning() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("too old, rejecting."));
       socket->close(); return;
     }
 
@@ -474,7 +475,7 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) {
 #ifndef QT_NO_OPENSSL
     // after we told the client that we are ssl capable we switch to ssl mode
     if(supportSsl && msg["UseSsl"].toBool()) {
-      qDebug() << qPrintable(tr("Starting TLS for Client:"))  << qPrintable(socket->peerAddress().toString());
+      quDebug() << qPrintable(tr("Starting TLS for Client:"))  << qPrintable(socket->peerAddress().toString());
       connect(sslSocket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(sslErrors(const QList<QSslError> &)));
       sslSocket->startServerEncryption();
     }
@@ -483,7 +484,7 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) {
 #ifndef QT_NO_COMPRESS
     if(supportsCompression && msg["UseCompression"].toBool()) {
       socket->setProperty("UseCompression", true);
-      qDebug() << "Using compression for Client:" << qPrintable(socket->peerAddress().toString());
+      quDebug() << "Using compression for Client: " << qPrintable(socket->peerAddress().toString());
     }
 #endif
     
@@ -494,7 +495,7 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) {
       reply["MsgType"] = "ClientLoginReject";
       reply["Error"] = tr("<b>Client not initialized!</b><br>You need to send an init message before trying to login.");
       SignalProxy::writeDataToDevice(socket, reply);
-      qWarning() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("did not send an init message before trying to login, rejecting."));
+      quWarning() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("did not send an init message before trying to login, rejecting."));
       socket->close(); return;
     }
     if(msg["MsgType"] == "CoreSetupData") {
@@ -520,7 +521,7 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) {
       }
       reply["MsgType"] = "ClientLoginAck";
       SignalProxy::writeDataToDevice(socket, reply);
-      qDebug() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("initialized and authenticated successfully as \"%1\" (UserId: %2).").arg(msg["User"].toString()).arg(uid.toInt()));
+      quInfo() << qPrintable(tr("Client ")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr(" initialized and authenticated successfully as \"%1\" (UserId: %2).").arg(msg["User"].toString()).arg(uid.toInt()));
       setupClientSession(socket, uid);
     }
   }
@@ -531,13 +532,13 @@ void Core::clientDisconnected() {
   QTcpSocket *socket = qobject_cast<QTcpSocket *>(sender());
   if(socket) {
     // here it's safe to call methods on socket!
-    qDebug() << qPrintable(tr("Non-authed client disconnected.")) << qPrintable(socket->peerAddress().toString());
+    quInfo() << qPrintable(tr("Non-authed client disconnected.")) << qPrintable(socket->peerAddress().toString());
     blocksizes.remove(socket);
     clientInfo.remove(socket);
     socket->deleteLater();
   } else {
     // we have to crawl through the hashes and see if we find a victim to remove
-    qDebug() << qPrintable(tr("Non-authed client disconnected. (socket allready destroyed)"));
+    quDebug() << qPrintable(tr("Non-authed client disconnected. (socket allready destroyed)"));
 
     // DO NOT CALL ANY METHODS ON socket!!
     socket = static_cast<QTcpSocket *>(sender());
@@ -579,7 +580,7 @@ void Core::setupClientSession(QTcpSocket *socket, UserId uid) {
   blocksizes.remove(socket);
   clientInfo.remove(socket);
   if(!sess) {
-    qWarning() << qPrintable(tr("Could not initialize session for client:")) << qPrintable(socket->peerAddress().toString());
+    quWarning() << qPrintable(tr("Could not initialize session for client:")) << qPrintable(socket->peerAddress().toString());
     socket->close();
   }
   sess->addClient(socket);
@@ -587,7 +588,7 @@ void Core::setupClientSession(QTcpSocket *socket, UserId uid) {
 
 SessionThread *Core::createSession(UserId uid, bool restore) {
   if(sessions.contains(uid)) {
-    qWarning() << "Calling createSession() when a session for the user already exists!";
+    quWarning() << "Calling createSession() when a session for the user already exists!";
     return 0;
   }
   SessionThread *sess = new SessionThread(uid, restore, this);
@@ -608,5 +609,5 @@ void Core::sslErrors(const QList<QSslError> &errors) {
 void Core::socketError(QAbstractSocket::SocketError err) {
   QAbstractSocket *socket = qobject_cast<QAbstractSocket *>(sender());
   if(socket && err != QAbstractSocket::RemoteHostClosedError)
-    qDebug() << "Core::socketError()" << socket << err << socket->errorString();
+    quWarning() << "Core::socketError()" << socket << err << socket->errorString();
 }
index cdcf185..e22a67d 100644 (file)
@@ -21,6 +21,8 @@
 #include "corenetwork.h"
 #include "coresession.h"
 
+#include "logger.h"
+
 CoreNetwork::CoreNetwork(const NetworkId &networkid, CoreSession *session)
   : Network(networkid, session),
     _coreSession(session)
@@ -29,7 +31,7 @@ CoreNetwork::CoreNetwork(const NetworkId &networkid, CoreSession *session)
 
 void CoreNetwork::requestConnect() const {
   if(connectionState() != Disconnected) {
-    qWarning() << "Requesting connect while already being connected!";
+    quWarning() << "Requesting connect while already being connected!";
     return;
   }
   emit connectRequested(networkId());
@@ -37,7 +39,7 @@ void CoreNetwork::requestConnect() const {
 
 void CoreNetwork::requestDisconnect() const {
   if(connectionState() == Disconnected) {
-    qWarning() << "Requesting disconnect while not being connected!";
+    quWarning() << "Requesting disconnect while not being connected!";
     return;
   }
   emit disconnectRequested(networkId());
index 696825d..2be0e09 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "util.h"
 #include "coreusersettings.h"
+#include "logger.h"
 
 CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent)
   : QObject(parent),
@@ -142,13 +143,13 @@ void CoreSession::loadSettings() {
   foreach(IdentityId id, s.identityIds()) {
     Identity *i = new Identity(s.identity(id), this);
     if(!i->isValid()) {
-      qWarning() << QString("Invalid identity! Removing...");
+      quWarning() << "Invalid identity! Removing...";
       s.removeIdentity(id);
       delete i;
       continue;
     }
     if(_identities.contains(i->id())) {
-      qWarning() << "Duplicate identity, ignoring!";
+      quWarning() << "Duplicate identity, ignoring!";
       delete i;
       continue;
     }
@@ -185,7 +186,7 @@ void CoreSession::updateBufferInfo(UserId uid, const BufferInfo &bufinfo) {
 void CoreSession::connectToNetwork(NetworkId id) {
   CoreNetwork *net = network(id);
   if(!net) {
-    qWarning() << "Connect to unknown network requested! net:" << id << "user:" << user();
+    quWarning() << "Connect to unknown network requested! net: " << id << " user: " << user();
     return;
   }
 
@@ -232,7 +233,7 @@ void CoreSession::networkStateRequested() {
 void CoreSession::addClient(QObject *dev) { // this is QObject* so we can use it in signal connections
   QIODevice *device = qobject_cast<QIODevice *>(dev);
   if(!device) {
-    qWarning() << "Invoking CoreSession::addClient with a QObject that is not a QIODevice!";
+    quError() << "Invoking CoreSession::addClient with a QObject that is not a QIODevice!";
   } else {
     signalProxy()->addPeer(device);
     QVariantMap reply;
@@ -246,9 +247,9 @@ void CoreSession::removeClient(QIODevice *iodev) {
   // no checks for validity check - privateslot...
   QTcpSocket *socket = qobject_cast<QTcpSocket *>(iodev);
   if(socket)
-    qDebug() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("disconnected (UserId: %1).").arg(user().toInt()));
+    quInfo() << qPrintable(tr("Client ")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr(" disconnected (UserId: %1).").arg(user().toInt()));
   else
-    qDebug() << "Local client disconnedted.";
+    quInfo() << "Local client disconnedted.";
   disconnect(socket, 0, this, 0);
   socket->deleteLater();
 }
@@ -293,7 +294,7 @@ void CoreSession::msgFromClient(BufferInfo bufinfo, QString msg) {
   if(conn) {
     conn->userInput(bufinfo, msg);
   } else {
-    qWarning() << "Trying to send to unconnected network:" << msg;
+    quWarning() << "Trying to send to unconnected network:" << msg;
   }
 }
 
@@ -386,7 +387,7 @@ void CoreSession::createIdentity(const Identity &id) {
 
 void CoreSession::updateIdentity(const Identity &id) {
   if(!_identities.contains(id.id())) {
-    qWarning() << "Update request for unknown identity received!";
+    quWarning() << "Update request for unknown identity received!";
     return;
   }
   _identities[id.id()]->update(id);
@@ -415,7 +416,7 @@ void CoreSession::createNetwork(const NetworkInfo &info_) {
     Core::createNetwork(user(), info);
 
   if(!info.networkId.isValid()) {
-    qWarning() << qPrintable(tr("CoreSession::createNetwork(): Got invalid networkId from Core when trying to create network %1!").arg(info.networkName));
+    quWarning() << qPrintable(tr("CoreSession::createNetwork(): Got invalid networkId from Core when trying to create network %1!").arg(info.networkName));
     return;
   }
 
@@ -430,7 +431,7 @@ void CoreSession::createNetwork(const NetworkInfo &info_) {
     signalProxy()->synchronize(net);
     emit networkCreated(id);
   } else {
-    qWarning() << qPrintable(tr("CoreSession::createNetwork(): Trying to create a network that already exists, updating instead!"));
+    quWarning() << qPrintable(tr("CoreSession::createNetwork(): Trying to create a network that already exists, updating instead!"));
     updateNetwork(info);
   }
 }
@@ -438,7 +439,7 @@ void CoreSession::createNetwork(const NetworkInfo &info_) {
 // FIXME: move to CoreNetwork
 void CoreSession::updateNetwork(const NetworkInfo &info) {
   if(!_networks.contains(info.networkId)) {
-    qWarning() << "Update request for unknown network received!";
+    quWarning() << "Update request for unknown network received!";
     return;
   }
   _networks[info.networkId]->setNetworkInfo(info);
@@ -480,24 +481,24 @@ void CoreSession::destroyNetwork(NetworkId id) {
 void CoreSession::removeBufferRequested(BufferId bufferId) {
   BufferInfo bufferInfo = Core::getBufferInfo(user(), bufferId);
   if(!bufferInfo.isValid()) {
-    qWarning() << "CoreSession::removeBufferRequested(): invalid BufferId:" << bufferId << "for User:" << user();
+    quWarning() << "CoreSession::removeBufferRequested(): invalid BufferId: " << bufferId << " for User: " << user();
     return;
   }
   
   if(bufferInfo.type() == BufferInfo::StatusBuffer) {
-    qWarning() << "CoreSession::removeBufferRequested(): Status Buffers cannot be removed!";
+    quWarning() << "CoreSession::removeBufferRequested(): Status Buffers cannot be removed!";
     return;
   }
   
   if(bufferInfo.type() == BufferInfo::ChannelBuffer) {
     CoreNetwork *net = network(bufferInfo.networkId());
     if(!net) {
-      qWarning() << "CoreSession::removeBufferRequested(): Received BufferInfo with unknown networkId!";
+      quWarning() << "CoreSession::removeBufferRequested(): Received BufferInfo with unknown networkId!";
       return;
     }
     IrcChannel *chan = net->ircChannel(bufferInfo.bufferName());
     if(chan) {
-      qWarning() << "CoreSession::removeBufferRequested(): Unable to remove Buffer for joined Channel:" << bufferInfo.bufferName();
+      quWarning() << "CoreSession::removeBufferRequested(): Unable to remove Buffer for joined Channel: " << bufferInfo.bufferName();
       return;
     }
   }
index ec3789d..7604cd2 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "ircuser.h"
 #include "ircchannel.h"
+#include "logger.h"
 
 #include <QDebug>
 
@@ -47,7 +48,7 @@ IrcServerHandler::~IrcServerHandler() {
 void IrcServerHandler::handleServerMsg(QByteArray msg) {
   try {
     if(msg.isEmpty()) {
-      qWarning() << "Received empty string from server!";
+      quWarning() << "Received empty string from server!";
       return;
     }
 
@@ -67,7 +68,7 @@ void IrcServerHandler::handleServerMsg(QByteArray msg) {
     QList<QByteArray> params = msg.split(' ');
     if(!trailing.isEmpty()) params << trailing;
     if(params.count() < 1) {
-      qWarning() << "Received invalid string from server!";
+      quWarning() << "Received invalid string from server!";
       return;
     }
 
@@ -78,7 +79,7 @@ void IrcServerHandler::handleServerMsg(QByteArray msg) {
       foo.remove(0, 1);
       prefix = foo;
       if(params.count() < 1) {
-        qWarning() << "Received invalid string from server!";
+        quWarning() << "Received invalid string from server!";
         return;
       }
       foo = serverDecode(params.takeFirst());
@@ -91,7 +92,7 @@ void IrcServerHandler::handleServerMsg(QByteArray msg) {
     uint num = cmd.toUInt();
     if(num > 0) {
       if(params.count() == 0) {
-        qWarning() << "Message received from server violates RFC and is ignored!";
+        quWarning() << "Message received from server violates RFC and is ignored!";
         return;
       }
       params.removeFirst();
@@ -237,7 +238,7 @@ void IrcServerHandler::handleMode(const QString &prefix, const QList<QByteArray>
          else
            channel->removeUserMode(ircUser, QString(modes[c]));
        } else {
-         qWarning() << "Received MODE with too few parameters:" << serverDecode(params);
+         quWarning() << "Received MODE with too few parameters: " << serverDecode(params);
        }
        paramOffset++;
       } else {
@@ -248,7 +249,7 @@ void IrcServerHandler::handleMode(const QString &prefix, const QList<QByteArray>
            if(paramOffset < params.count()) {
              value = params[paramOffset];
            } else {
-             qWarning() << "Received MODE with too few parameters:" << serverDecode(params);
+             quWarning() << "Received MODE with too few parameters: " << serverDecode(params);
            }
            paramOffset++;
        }
@@ -297,7 +298,7 @@ void IrcServerHandler::handleNick(const QString &prefix, const QList<QByteArray>
 
   IrcUser *ircuser = network()->updateNickFromMask(prefix);
   if(!ircuser) {
-    qWarning() << "IrcServerHandler::handleNick(): Unknown IrcUser!";
+    quWarning() << "IrcServerHandler::handleNick(): Unknown IrcUser!";
     return;
   }
   QString newnick = serverDecode(params[0]);
@@ -334,7 +335,7 @@ void IrcServerHandler::handlePart(const QString &prefix, const QList<QByteArray>
   IrcUser *ircuser = network()->updateNickFromMask(prefix);
   QString channel = serverDecode(params[0]);
   if(!ircuser) {
-    qWarning() << "IrcServerHandler::handlePart(): Unknown IrcUser!";
+    quWarning() << "IrcServerHandler::handlePart(): Unknown IrcUser!";
     return;
   }
 
@@ -376,12 +377,12 @@ void IrcServerHandler::handlePrivmsg(const QString &prefix, const QList<QByteArr
 
   IrcUser *ircuser = network()->updateNickFromMask(prefix);
   if(!ircuser) {
-    qWarning() << "IrcServerHandler::handlePrivmsg(): Unknown IrcUser!";
+    quWarning() << "IrcServerHandler::handlePrivmsg(): Unknown IrcUser!";
     return;
   }
 
   if(params.isEmpty()) {
-    qWarning() << "IrcServerHandler::handlePrivmsg(): received PRIVMSG without target or message from:" << prefix;
+    quWarning() << "IrcServerHandler::handlePrivmsg(): received PRIVMSG without target or message from: " << prefix;
     return;
   }
      
@@ -862,7 +863,7 @@ void IrcServerHandler::handle353(const QString &prefix, const QList<QByteArray>
 
   IrcChannel *channel = network()->ircChannel(channelname);
   if(!channel) {
-    qWarning() << "IrcServerHandler::handle353(): received unknown target channel:" << channelname;
+    quWarning() << "IrcServerHandler::handle353(): received unknown target channel: " << channelname;
     return;
   }
 
@@ -946,7 +947,7 @@ void IrcServerHandler::tryNextNick(const QString &errnick) {
 
 bool IrcServerHandler::checkParamCount(const QString &methodName, const QList<QByteArray> &params, int minParams) {
   if(params.count() < minParams) {
-    qWarning() << qPrintable(methodName) << "requieres" << minParams << "parameters but received only" << params.count() << serverDecode(params);
+    quWarning() << qPrintable(methodName) << " requires " << minParams << " parameters but received only " << params.count() << serverDecode(params);
     return false;
   } else {
     return true;
index 617433f..6713765 100644 (file)
@@ -35,6 +35,8 @@
 #include "userinputhandler.h"
 #include "ctcphandler.h"
 
+#include "logger.h"
+
 NetworkConnection::NetworkConnection(Network *network, CoreSession *session)
   : QObject(network),
     _connectionState(Network::Disconnected),
@@ -177,11 +179,11 @@ void NetworkConnection::connectToIrc(bool reconnecting) {
   QVariantList serverList = network()->serverList();
   Identity *identity = coreSession()->identity(network()->identity());
   if(!serverList.count()) {
-    qWarning() << "Server list empty, ignoring connect request!";
+    quWarning() << "Server list empty, ignoring connect request!";
     return;
   }
   if(!identity) {
-    qWarning() << "Invalid identity configures, ignoring connect request!";
+    quWarning() << "Invalid identity configures, ignoring connect request!";
     return;
   }
   // use a random server?
@@ -276,7 +278,7 @@ void NetworkConnection::socketHasData() {
 
 void NetworkConnection::socketError(QAbstractSocket::SocketError) {
   _previousConnectionAttemptFailed = true;
-  qDebug() << qPrintable(tr("Could not connect to %1 (%2)").arg(network()->networkName(), socket.errorString()));
+  quWarning() << qPrintable(tr("Could not connect to %1 (%2)").arg(network()->networkName(), socket.errorString()));
   emit connectionError(socket.errorString());
   emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", tr("Connection failure: %1").arg(socket.errorString()));
   network()->emitConnectionError(socket.errorString());
@@ -333,7 +335,7 @@ void NetworkConnection::socketInitialized() {
   //emit connected(networkId());  initialize first!
   Identity *identity = coreSession()->identity(network()->identity());
   if(!identity) {
-    qWarning() << "Identity invalid!";
+    quError() << "Identity invalid!";
     disconnectFromIrc();
     return;
   }
@@ -396,7 +398,7 @@ void NetworkConnection::socketDisconnected() {
 
 void NetworkConnection::doAutoReconnect() {
   if(connectionState() != Network::Disconnected && connectionState() != Network::Reconnecting) {
-    qWarning() << "NetworkConnection::doAutoReconnect(): Cannot reconnect while not being disconnected!";
+    quWarning() << "NetworkConnection::doAutoReconnect(): Cannot reconnect while not being disconnected!";
     return;
   }
   if(_autoReconnectCount > 0) _autoReconnectCount--;
index ee83f87..84b7776 100644 (file)
@@ -25,6 +25,7 @@
 #include "network.h"
 
 #include "util.h"
+#include "logger.h"
 
 SqliteStorage::SqliteStorage(QObject *parent)
   : AbstractSqlStorage(parent)
@@ -256,7 +257,7 @@ bool SqliteStorage::removeNetwork(UserId user, const NetworkId &networkId) {
   if(withTransaction) {
     sync();
     if(!logDb().transaction()) {
-      qWarning() << "SqliteStorage::removeNetwork(): cannot start transaction. continuing with out rollback support!";
+      quWarning() << "SqliteStorage::removeNetwork(): cannot start transaction. continuing with out rollback support!";
       withTransaction = false;
     }
   }
@@ -490,16 +491,19 @@ BufferInfo SqliteStorage::getBufferInfo(UserId user, const NetworkId &networkId,
     query->exec();
     if(!query->first()) {
       watchQuery(query);
-      qWarning() << "unable to create BufferInfo for:" << user << networkId << buffer;
+      quWarning() << "unable to create BufferInfo for: " << user << networkId << buffer;
       return BufferInfo();
     }
   }
 
   BufferInfo bufferInfo = BufferInfo(query->value(0).toInt(), networkId, (BufferInfo::Type)query->value(1).toInt(), 0, buffer);
   if(query->next()) {
-    qWarning() << "SqliteStorage::getBufferInfo(): received more then one Buffer!";
-    qWarning() << "         Query:" << query->lastQuery();
-    qWarning() << "  bound Values:" << query->boundValues();
+    quError() << "SqliteStorage::getBufferInfo(): received more then one Buffer!";
+    quError() << "         Query: " << query->lastQuery();
+    quError() << "  bound Values:";
+    QList<QVariant> list = query->boundValues().values();
+    for (int i = 0; i < list.size(); ++i)
+      quError() << i << ": " << list.at(i).toString().toAscii().data();
     Q_ASSERT(false);
   }
 
@@ -809,7 +813,7 @@ bool SqliteStorage::init(const QVariantMap &settings) {
   getPasswordsQuery.exec();
 
   if(!watchQuery(&getPasswordsQuery)) {
-    qWarning() << "unable to migrate to new password format!";
+    quError() << "unable to migrate to new password format!";
     return false;
   }
 
@@ -827,6 +831,6 @@ bool SqliteStorage::init(const QVariantMap &settings) {
     watchQuery(&setPasswordsQuery);
   }
 
-  qDebug() << "successfully migrated passwords!";
+  quDebug() << "successfully migrated passwords!";
   return true;
 }
index 5a61a31..307c46b 100644 (file)
@@ -27,6 +27,7 @@
 #include <QFile>
 #include <QDebug>
 
+#include "logger.h"
 #include "util.h"
 
 #ifndef QT_NO_OPENSSL
@@ -45,7 +46,7 @@ SslServer::SslServer(QObject *parent)
 
   _certIsValid = !_cert.isNull() && _cert.isValid() && !_key.isNull();
   if(!_certIsValid) {
-    qWarning() << "SslServer: SSL Certificate is either missing or has a wrong format!\n"
+    quWarning() << "SslServer: SSL Certificate is either missing or has a wrong format!\n"
                << "          Quassel Core will still work, but cannot provide SSL for client connections.\n"
                << "          Please see http://quassel-irc.org/faq/cert to learn how to enable SSL support.";
   }