From: Marcus Eggenberger Date: Thu, 30 Oct 2008 13:17:23 +0000 (+0100) Subject: Improved debuging: X-Git-Tag: 0.3.1~104 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=034708a59ca1ee3195263a90941a2b145c520fef Improved debuging: - client debug messages are accessible via menu: help -> debug -> debug log - the crash log contains now build information and output of asserts --- diff --git a/src/client/client.cpp b/src/client/client.cpp index b0be2a3d..f981040e 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -35,6 +35,7 @@ #include "messagemodel.h" #include "network.h" #include "networkmodel.h" +#include "quassel.h" #include "quasselui.h" #include "signalproxy.h" #include "util.h" @@ -76,7 +77,8 @@ Client::Client(QObject *parent) _messageModel(0), _messageProcessor(0), _connectedToCore(false), - _syncedToCore(false) + _syncedToCore(false), + _debugLog(&_debugLogBuffer) { _signalProxy->synchronize(_ircListHelper); } @@ -362,9 +364,9 @@ void Client::recvStatusMsg(QString /*net*/, QString /*msg*/) { //recvMessage(net, Message::server("", QString("[STATUS] %1").arg(msg))); } -void Client::recvMessage(const Message &msg_) { - Message msg = msg_; - messageProcessor()->process(msg); +void Client::recvMessage(const Message &msg) { + Message msg_ = msg; + messageProcessor()->process(msg_); } void Client::setBufferLastSeenMsg(BufferId id, const MsgId &msgId) { @@ -402,3 +404,24 @@ void Client::bufferRenamed(BufferId bufferId, const QString &newName) { networkModel()->setData(bufferIndex, newName, Qt::DisplayRole); } } + +void Client::logMessage(QtMsgType type, const char *msg) { + QString prefix; + switch (type) { + case QtDebugMsg: + prefix = "Debug"; + break; + case QtWarningMsg: + prefix = "Warning"; + break; + case QtCriticalMsg: + prefix = "Critical"; + break; + case QtFatalMsg: + Quassel::logFatalMessage(msg); + return; + } + instance()->_debugLog << prefix << ": " << msg << "\n"; + emit instance()->logUpdated(); +} + diff --git a/src/client/client.h b/src/client/client.h index b8faf9fb..52133b68 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -112,6 +112,9 @@ public: static void setBufferLastSeenMsg(BufferId id, const MsgId &msgId); // this is synced to core and other clients static void removeBuffer(BufferId id); + static void logMessage(QtMsgType type, const char *msg); + static inline const QString &debugLog() { return instance()->_debugLogBuffer; } + signals: void sendInput(BufferInfo, QString message); void requestNetworkStates(); @@ -149,6 +152,8 @@ signals: void newClientSyncer(ClientSyncer *); + void logUpdated(); + public slots: //void selectBuffer(Buffer *); @@ -207,6 +212,9 @@ private: static AccountId _currentCoreAccount; + QString _debugLogBuffer; + QTextStream _debugLog; + friend class ClientSyncer; }; diff --git a/src/common/logger.cpp b/src/common/logger.cpp index fbee7248..17c473b5 100644 --- a/src/common/logger.cpp +++ b/src/common/logger.cpp @@ -58,3 +58,22 @@ void Logger::log() { out << _buffer << endl; if(file.isOpen()) file.close(); } + + +void Logger::logMessage(QtMsgType type, const char *msg) { + switch (type) { + case QtDebugMsg: + Logger(Logger::DebugLevel) << msg; + break; + case QtWarningMsg: + Logger(Logger::WarningLevel) << msg; + break; + case QtCriticalMsg: + Logger(Logger::ErrorLevel) << msg; + break; + case QtFatalMsg: + Logger(Logger::ErrorLevel) << msg; + Quassel::logFatalMessage(msg); + return; + } +} diff --git a/src/common/logger.h b/src/common/logger.h index f5a6ff59..d9b51a63 100644 --- a/src/common/logger.h +++ b/src/common/logger.h @@ -28,46 +28,34 @@ #include class Logger { - public: - enum LogLevel { - DebugLevel, - InfoLevel, - WarningLevel, - ErrorLevel - }; - - inline Logger(LogLevel level) : _stream(&_buffer, QIODevice::WriteOnly), _logLevel(level) {} - ~Logger(); - - template - inline Logger &operator<<(const T &value) { _stream << value << " "; return *this; } - inline Logger &operator<<(const QStringList & t) { _stream << t.join(" ") << " "; return *this; } - inline Logger &operator<<(bool t) { _stream << (t ? "true" : "false") << " "; return *this; } - - private: - void log(); - QTextStream _stream; - QString _buffer; - LogLevel _logLevel; -}; - -class quDebug : public Logger { - public: - inline quDebug() : Logger(Logger::DebugLevel) {} +public: + enum LogLevel { + DebugLevel, + InfoLevel, + WarningLevel, + ErrorLevel + }; + + inline Logger(LogLevel level) : _stream(&_buffer, QIODevice::WriteOnly), _logLevel(level) {} + ~Logger(); + + static void logMessage(QtMsgType type, const char *msg); + + template + inline Logger &operator<<(const T &value) { _stream << value << " "; return *this; } + inline Logger &operator<<(const QStringList & t) { _stream << t.join(" ") << " "; return *this; } + inline Logger &operator<<(bool t) { _stream << (t ? "true" : "false") << " "; return *this; } + +private: + void log(); + QTextStream _stream; + QString _buffer; + LogLevel _logLevel; }; class quInfo : public Logger { - public: - inline quInfo() : Logger(Logger::InfoLevel) {} -}; - -class quWarning : public Logger { - public: - inline quWarning() : Logger(Logger::WarningLevel) {} +public: + inline quInfo() : Logger(Logger::InfoLevel) {} }; -class quError : public Logger { - public: - inline quError() : Logger(Logger::ErrorLevel) {} -}; #endif diff --git a/src/common/quassel.cpp b/src/common/quassel.cpp index dd6c5e70..e54d8946 100644 --- a/src/common/quassel.cpp +++ b/src/common/quassel.cpp @@ -46,6 +46,7 @@ CliParser *Quassel::_cliParser = 0; Quassel::RunMode Quassel::_runMode; bool Quassel::_initialized = false; bool Quassel::DEBUG = false; +QString Quassel::_coreDumpFileName; Quassel::Quassel() { Q_INIT_RESOURCE(i18n); @@ -224,15 +225,33 @@ void Quassel::handleSignal(int sig) { } } +void Quassel::logFatalMessage(const char *msg) { +#ifndef Q_OS_MAC + QFile dumpFile(coreDumpFileName()); + dumpFile.open(QIODevice::WriteOnly); + QTextStream dumpStream(&dumpFile); +#else + QTextStream dumpStream(stderr); +#endif + + dumpStream << "Fatal: " << msg << '\n'; + dumpStream.flush(); + + qInstallMsgHandler(0); + abort(); +} + void Quassel::handleCrash() { #ifdef BUILD_CRASHHANDLER void* callstack[128]; int i, frames = backtrace(callstack, 128); - QFile dumpFile(QString("Quassel-Crash-%1").arg(QDateTime::currentDateTime().toString("yyyyMMdd-hhmm.log"))); - dumpFile.open(QIODevice::WriteOnly); + QFile dumpFile(coreDumpFileName()); + dumpFile.open(QIODevice::Append); QTextStream dumpStream(&dumpFile); + dumpStream << "Quassel IRC: " << _buildInfo.baseVersion << ' ' << _buildInfo.commitHash << '\n'; + for (i = 0; i < frames; ++i) { Dl_info info; dladdr (callstack[i], &info); @@ -287,3 +306,10 @@ void Quassel::handleCrash() { exit(27); #endif /* BUILD_CRASHHANDLER */ } + +const QString &Quassel::coreDumpFileName() { + if(_coreDumpFileName.isEmpty()) + _coreDumpFileName = QString("Quassel-Crash-%1.log").arg(QDateTime::currentDateTime().toString("yyyyMMdd-hhmm")); + + return _coreDumpFileName; +} diff --git a/src/common/quassel.h b/src/common/quassel.h index bed6eac3..a9fe53c6 100644 --- a/src/common/quassel.h +++ b/src/common/quassel.h @@ -29,65 +29,70 @@ class Quassel { Q_DECLARE_TR_FUNCTIONS(Quassel) - public: - enum RunMode { - Monolithic, - ClientOnly, - CoreOnly - }; +public: + enum RunMode { + Monolithic, + ClientOnly, + CoreOnly + }; - struct BuildInfo { - QString fancyVersionString; // clickable rev - QString plainVersionString; // no tag + struct BuildInfo { + QString fancyVersionString; // clickable rev + QString plainVersionString; // no tag - QString baseVersion; - QString generatedVersion; - QString commitHash; - uint commitDate; - QString buildDate; - bool isSourceDirty; - uint protocolVersion; - uint clientNeedsProtocol; - uint coreNeedsProtocol; + QString baseVersion; + QString generatedVersion; + QString commitHash; + uint commitDate; + QString buildDate; + bool isSourceDirty; + uint protocolVersion; + uint clientNeedsProtocol; + uint coreNeedsProtocol; - QString applicationName; - QString coreApplicationName; - QString clientApplicationName; - QString organizationName; - QString organizationDomain; - }; + QString applicationName; + QString coreApplicationName; + QString clientApplicationName; + QString organizationName; + QString organizationDomain; + }; - void setupBuildInfo(const QString &generated); + void setupBuildInfo(const QString &generated); - virtual ~Quassel(); + virtual ~Quassel(); - static inline const BuildInfo & buildInfo(); - static inline RunMode runMode(); + static inline const BuildInfo & buildInfo(); + static inline RunMode runMode(); - static inline CliParser *cliParser(); - static inline QString optionValue(const QString &option); - static inline bool isOptionSet(const QString &option); + static inline CliParser *cliParser(); + static inline QString optionValue(const QString &option); + static inline bool isOptionSet(const QString &option); - static bool DEBUG; + static const QString &coreDumpFileName(); - protected: - Quassel(); - virtual bool init(); + static bool DEBUG; - inline void setRunMode(RunMode mode); + static void logFatalMessage(const char *msg); +protected: + Quassel(); + virtual bool init(); - private: - void setupTranslations(); - void registerMetaTypes(); + inline void setRunMode(RunMode mode); - static void handleSignal(int signal); - static void handleCrash(); +private: + void setupTranslations(); + void registerMetaTypes(); - static BuildInfo _buildInfo; - static CliParser *_cliParser; - static RunMode _runMode; - static bool _initialized; + static void handleSignal(int signal); + static void handleCrash(); + + static BuildInfo _buildInfo; + static CliParser *_cliParser; + static RunMode _runMode; + static bool _initialized; + + static QString _coreDumpFileName; }; const Quassel::BuildInfo & Quassel::buildInfo() { return _buildInfo; } diff --git a/src/core/abstractsqlstorage.cpp b/src/core/abstractsqlstorage.cpp index 39198258..c6eeeec3 100644 --- a/src/core/abstractsqlstorage.cpp +++ b/src/core/abstractsqlstorage.cpp @@ -52,8 +52,8 @@ QSqlDatabase AbstractSqlStorage::logDb() { return db; if(!openDb()) { - quWarning() << "Unable to Open Database" << displayName(); - quWarning() << "-" << db.lastError().text(); + qWarning() << "Unable to Open Database" << displayName(); + qWarning() << "-" << db.lastError().text(); } return QSqlDatabase::database("quassel_connection"); @@ -85,17 +85,17 @@ bool AbstractSqlStorage::init(const QVariantMap &settings) { return false; if(installedSchemaVersion() == -1) { - quError() << "Storage Schema is missing!"; + qCritical() << "Storage Schema is missing!"; return false; } if(installedSchemaVersion() > schemaVersion()) { - quError() << "Installed Schema is newer then any known Version."; + qCritical() << "Installed Schema is newer then any known Version."; return false; } if(installedSchemaVersion() < schemaVersion()) { - quWarning() << "Installed Schema is not up to date. Upgrading..."; + qWarning() << "Installed Schema is not up to date. Upgrading..."; if(!upgradeDb()) return false; } @@ -120,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()) { - quError() << "Unable to read SQL-Query" << queryName << "for engine" << displayName(); + qCritical() << "Unable to read SQL-Query" << queryName << "for engine" << displayName(); return QString(); } @@ -164,14 +164,14 @@ bool AbstractSqlStorage::setup(const QVariantMap &settings) { Q_UNUSED(settings) QSqlDatabase db = logDb(); if(!db.isOpen()) { - quError() << "Unable to setup Logging Backend!"; + qCritical() << "Unable to setup Logging Backend!"; return false; } foreach(QString queryString, setupQueries()) { QSqlQuery query = db.exec(queryString); if(!watchQuery(&query)) { - quError() << "Unable to setup Logging Backend!"; + qCritical() << "Unable to setup Logging Backend!"; return false; } } @@ -197,7 +197,7 @@ bool AbstractSqlStorage::upgradeDb() { foreach(QString queryString, upgradeQueries(ver)) { QSqlQuery query = db.exec(queryString); if(!watchQuery(&query)) { - quError() << "Unable to upgrade Logging Backend!"; + qCritical() << "Unable to upgrade Logging Backend!"; return false; } } @@ -231,17 +231,17 @@ int AbstractSqlStorage::schemaVersion() { bool AbstractSqlStorage::watchQuery(QSqlQuery *query) { if(query->lastError().isValid()) { - quError() << "unhandled Error in QSqlQuery!"; - quError() << " last Query:\n" << query->lastQuery(); - quError() << " executed Query:\n" << query->executedQuery(); - quError() << " bound Values:"; + qCritical() << "unhandled Error in QSqlQuery!"; + qCritical() << " last Query:\n" << query->lastQuery(); + qCritical() << " executed Query:\n" << query->executedQuery(); + qCritical() << " bound Values:"; QList 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(); + qCritical() << i << ": " << list.at(i).toString().toAscii().data(); + qCritical() << " Error Number:" << query->lastError().number(); + qCritical() << " Error Message:" << query->lastError().text(); + qCritical() << " Driver Message:" << query->lastError().driverText(); + qCritical() << " DB Message:" << query->lastError().databaseText(); return false; } diff --git a/src/core/basichandler.cpp b/src/core/basichandler.cpp index 8b9fd03a..c7d0efbb 100644 --- a/src/core/basichandler.cpp +++ b/src/core/basichandler.cpp @@ -78,7 +78,7 @@ void BasicHandler::handle(const QString &member, QGenericArgument val0, if(!handlerHash().contains(handler)) { if(defaultHandler == -1) { - quWarning() << QString("No such Handler: %1::handle%2").arg(metaObject()->className(), handler); + qWarning() << 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(), diff --git a/src/core/core.cpp b/src/core/core.cpp index 6506061f..383526a0 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -56,8 +56,8 @@ Core::Core() : storage(0) { registerStorageBackend(new SqliteStorage(this)); if(!_storageBackends.count()) { - quWarning() << qPrintable(tr("Could not initialize any storage backend! Exiting...")); - quWarning() << qPrintable(tr("Currently, Quassel only supports SQLite3. You need to build your\n" + qWarning() << qPrintable(tr("Could not initialize any storage backend! Exiting...")); + qWarning() << 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) @@ -72,7 +72,7 @@ void Core::init() { CoreSettings cs; if(!(configured = initStorage(cs.storageSettings().toMap()))) { - quWarning() << "Core is currently not configured! Please connect with a Quassel Client for basic setup."; + qWarning() << "Core is currently not configured! Please connect with a Quassel Client for basic setup."; // try to migrate old settings QVariantMap old = cs.oldDbSettings().toMap(); @@ -80,7 +80,7 @@ void Core::init() { QVariantMap newSettings; newSettings["Backend"] = "SQLite"; if((configured = initStorage(newSettings))) { - quWarning() << "...but thankfully I found some old settings to migrate!"; + qWarning() << "...but thankfully I found some old settings to migrate!"; cs.setStorageSettings(newSettings); } } @@ -117,7 +117,7 @@ void Core::restoreState() { return; } if(instance()->sessions.count()) { - quWarning() << qPrintable(tr("Calling restoreState() even though active sessions exist!")); + qWarning() << qPrintable(tr("Calling restoreState() even though active sessions exist!")); return; } CoreSettings s; @@ -202,12 +202,12 @@ bool Core::initStorage(QVariantMap dbSettings, bool setup) { if(_storageBackends.contains(backend)) { storage = _storageBackends[backend]; } else { - quError() << "Selected storage backend is not available:" << backend; + qCritical() << "Selected storage backend is not available:" << backend; return configured = false; } if(!storage->init(dbSettings)) { if(!setup || !(storage->setup(dbSettings) && storage->init(dbSettings))) { - quError() << "Could not init storage!"; + qCritical() << "Could not init storage!"; storage = 0; return configured = false; } @@ -375,7 +375,7 @@ bool Core::startListening() { } if(!success) { - quError() << qPrintable(QString("Could not open GUI client port %1: %2").arg(port).arg(_server.errorString())); + qCritical() << qPrintable(QString("Could not open GUI client port %1: %2").arg(port).arg(_server.errorString())); } return success; @@ -432,7 +432,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 - quWarning() << qPrintable(tr("Antique client trying to connect... refusing.")); + qWarning() << qPrintable(tr("Antique client trying to connect... refusing.")); socket->close(); return; } @@ -448,7 +448,7 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) { "This core needs at least client/core protocol version %1.
" "Please consider upgrading your client.").arg(Quassel::buildInfo().coreNeedsProtocol); SignalProxy::writeDataToDevice(socket, reply); - quWarning() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("too old, rejecting.")); + qWarning() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("too old, rejecting.")); socket->close(); return; } @@ -508,7 +508,7 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) { #ifdef HAVE_SSL // after we told the client that we are ssl capable we switch to ssl mode if(supportSsl && msg["UseSsl"].toBool()) { - quDebug() << qPrintable(tr("Starting TLS for Client:")) << qPrintable(socket->peerAddress().toString()); + qDebug() << qPrintable(tr("Starting TLS for Client:")) << qPrintable(socket->peerAddress().toString()); connect(sslSocket, SIGNAL(sslErrors(const QList &)), this, SLOT(sslErrors(const QList &))); sslSocket->startServerEncryption(); } @@ -517,7 +517,7 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) { #ifndef QT_NO_COMPRESS if(supportsCompression && msg["UseCompression"].toBool()) { socket->setProperty("UseCompression", true); - quDebug() << "Using compression for Client:" << qPrintable(socket->peerAddress().toString()); + qDebug() << "Using compression for Client:" << qPrintable(socket->peerAddress().toString()); } #endif @@ -528,7 +528,7 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) { reply["MsgType"] = "ClientLoginReject"; reply["Error"] = tr("Client not initialized!
You need to send an init message before trying to login."); SignalProxy::writeDataToDevice(socket, reply); - quWarning() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("did not send an init message before trying to login, rejecting.")); + qWarning() << 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") { @@ -571,7 +571,7 @@ void Core::clientDisconnected() { socket->deleteLater(); } else { // we have to crawl through the hashes and see if we find a victim to remove - quDebug() << qPrintable(tr("Non-authed client disconnected. (socket allready destroyed)")); + qDebug() << qPrintable(tr("Non-authed client disconnected. (socket allready destroyed)")); // DO NOT CALL ANY METHODS ON socket!! socket = static_cast(sender()); @@ -613,7 +613,7 @@ void Core::setupClientSession(QTcpSocket *socket, UserId uid) { blocksizes.remove(socket); clientInfo.remove(socket); if(!sess) { - quWarning() << qPrintable(tr("Could not initialize session for client:")) << qPrintable(socket->peerAddress().toString()); + qWarning() << qPrintable(tr("Could not initialize session for client:")) << qPrintable(socket->peerAddress().toString()); socket->close(); } sess->addClient(socket); @@ -640,7 +640,7 @@ void Core::setupInternalClientSession(SignalProxy *proxy) { SessionThread *Core::createSession(UserId uid, bool restore) { if(sessions.contains(uid)) { - quWarning() << "Calling createSession() when a session for the user already exists!"; + qWarning() << "Calling createSession() when a session for the user already exists!"; return 0; } SessionThread *sess = new SessionThread(uid, restore, this); @@ -661,5 +661,5 @@ void Core::sslErrors(const QList &errors) { void Core::socketError(QAbstractSocket::SocketError err) { QAbstractSocket *socket = qobject_cast(sender()); if(socket && err != QAbstractSocket::RemoteHostClosedError) - quWarning() << "Core::socketError()" << socket << err << socket->errorString(); + qWarning() << "Core::socketError()" << socket << err << socket->errorString(); } diff --git a/src/core/coreapplication.cpp b/src/core/coreapplication.cpp index 3d8b1596..2cdc5a60 100644 --- a/src/core/coreapplication.cpp +++ b/src/core/coreapplication.cpp @@ -21,6 +21,7 @@ #include "coreapplication.h" #include "core.h" +#include "logger.h" CoreApplicationInternal::CoreApplicationInternal() : _coreCreated(false) @@ -67,9 +68,14 @@ bool CoreApplicationInternal::init() { /*****************************************************************************/ -CoreApplication::CoreApplication(int &argc, char **argv) : QCoreApplication(argc, argv), Quassel() { +CoreApplication::CoreApplication(int &argc, char **argv) + : QCoreApplication(argc, argv), + Quassel() +{ setRunMode(Quassel::CoreOnly); _internal = new CoreApplicationInternal(); + + qInstallMsgHandler(Logger::logMessage); } CoreApplication::~CoreApplication() { diff --git a/src/core/corenetwork.cpp b/src/core/corenetwork.cpp index 6a2149d4..a7cbd224 100644 --- a/src/core/corenetwork.cpp +++ b/src/core/corenetwork.cpp @@ -32,7 +32,7 @@ CoreNetwork::CoreNetwork(const NetworkId &networkid, CoreSession *session) void CoreNetwork::requestConnect() const { if(connectionState() != Disconnected) { - quWarning() << "Requesting connect while already being connected!"; + qWarning() << "Requesting connect while already being connected!"; return; } emit connectRequested(networkId()); @@ -40,7 +40,7 @@ void CoreNetwork::requestConnect() const { void CoreNetwork::requestDisconnect() const { if(connectionState() == Disconnected) { - quWarning() << "Requesting disconnect while not being connected!"; + qWarning() << "Requesting disconnect while not being connected!"; return; } emit disconnectRequested(networkId()); diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index 0dd33587..acb9aa23 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -140,13 +140,13 @@ void CoreSession::loadSettings() { foreach(IdentityId id, s.identityIds()) { Identity *i = new Identity(s.identity(id), this); if(!i->isValid()) { - quWarning() << "Invalid identity! Removing..."; + qWarning() << "Invalid identity! Removing..."; s.removeIdentity(id); delete i; continue; } if(_identities.contains(i->id())) { - quWarning() << "Duplicate identity, ignoring!"; + qWarning() << "Duplicate identity, ignoring!"; delete i; continue; } @@ -184,7 +184,7 @@ void CoreSession::updateBufferInfo(UserId uid, const BufferInfo &bufinfo) { void CoreSession::connectToNetwork(NetworkId id) { CoreNetwork *net = network(id); if(!net) { - quWarning() << "Connect to unknown network requested! net:" << id << "user:" << user(); + qWarning() << "Connect to unknown network requested! net:" << id << "user:" << user(); return; } @@ -230,7 +230,7 @@ void CoreSession::networkStateRequested() { void CoreSession::addClient(QIODevice *device) { if(!device) { - quError() << "Invoking CoreSession::addClient with a QObject that is not a QIODevice!"; + qCritical() << "Invoking CoreSession::addClient with a QObject that is not a QIODevice!"; } else { // if the socket is an orphan, the signalProxy adopts it. // -> we don't need to care about it anymore @@ -294,7 +294,7 @@ void CoreSession::msgFromClient(BufferInfo bufinfo, QString msg) { if(conn) { conn->userInput(bufinfo, msg); } else { - quWarning() << "Trying to send to unconnected network:" << msg; + qWarning() << "Trying to send to unconnected network:" << msg; } } @@ -399,7 +399,7 @@ void CoreSession::removeIdentity(IdentityId id) { void CoreSession::identityUpdated(const QVariantMap &data) { IdentityId id = data.value("identityId", 0).value(); if(!id.isValid() || !_identities.contains(id)) { - quWarning() << "Update request for unknown identity received!"; + qWarning() << "Update request for unknown identity received!"; return; } CoreUserSettings s(user()); @@ -416,7 +416,7 @@ void CoreSession::createNetwork(const NetworkInfo &info_) { Core::createNetwork(user(), info); if(!info.networkId.isValid()) { - quWarning() << qPrintable(tr("CoreSession::createNetwork(): Got invalid networkId from Core when trying to create network %1!").arg(info.networkName)); + qWarning() << qPrintable(tr("CoreSession::createNetwork(): Got invalid networkId from Core when trying to create network %1!").arg(info.networkName)); return; } @@ -431,7 +431,7 @@ void CoreSession::createNetwork(const NetworkInfo &info_) { signalProxy()->synchronize(net); emit networkCreated(id); } else { - quWarning() << qPrintable(tr("CoreSession::createNetwork(): Trying to create a network that already exists, updating instead!")); + qWarning() << qPrintable(tr("CoreSession::createNetwork(): Trying to create a network that already exists, updating instead!")); _networks[info.networkId]->requestSetNetworkInfo(info); } } @@ -471,24 +471,24 @@ void CoreSession::destroyNetwork(NetworkId id) { void CoreSession::removeBufferRequested(BufferId bufferId) { BufferInfo bufferInfo = Core::getBufferInfo(user(), bufferId); if(!bufferInfo.isValid()) { - quWarning() << "CoreSession::removeBufferRequested(): invalid BufferId:" << bufferId << "for User:" << user(); + qWarning() << "CoreSession::removeBufferRequested(): invalid BufferId:" << bufferId << "for User:" << user(); return; } if(bufferInfo.type() == BufferInfo::StatusBuffer) { - quWarning() << "CoreSession::removeBufferRequested(): Status Buffers cannot be removed!"; + qWarning() << "CoreSession::removeBufferRequested(): Status Buffers cannot be removed!"; return; } if(bufferInfo.type() == BufferInfo::ChannelBuffer) { CoreNetwork *net = network(bufferInfo.networkId()); if(!net) { - quWarning() << "CoreSession::removeBufferRequested(): Received BufferInfo with unknown networkId!"; + qWarning() << "CoreSession::removeBufferRequested(): Received BufferInfo with unknown networkId!"; return; } IrcChannel *chan = net->ircChannel(bufferInfo.bufferName()); if(chan) { - quWarning() << "CoreSession::removeBufferRequested(): Unable to remove Buffer for joined Channel:" << bufferInfo.bufferName(); + qWarning() << "CoreSession::removeBufferRequested(): Unable to remove Buffer for joined Channel:" << bufferInfo.bufferName(); return; } } diff --git a/src/core/ircserverhandler.cpp b/src/core/ircserverhandler.cpp index f4660656..93076ec5 100644 --- a/src/core/ircserverhandler.cpp +++ b/src/core/ircserverhandler.cpp @@ -48,7 +48,7 @@ IrcServerHandler::~IrcServerHandler() { void IrcServerHandler::handleServerMsg(QByteArray msg) { try { if(msg.isEmpty()) { - quWarning() << "Received empty string from server!"; + qWarning() << "Received empty string from server!"; return; } @@ -68,7 +68,7 @@ void IrcServerHandler::handleServerMsg(QByteArray msg) { QList params = msg.split(' '); if(!trailing.isEmpty()) params << trailing; if(params.count() < 1) { - quWarning() << "Received invalid string from server!"; + qWarning() << "Received invalid string from server!"; return; } @@ -79,7 +79,7 @@ void IrcServerHandler::handleServerMsg(QByteArray msg) { foo.remove(0, 1); prefix = foo; if(params.count() < 1) { - quWarning() << "Received invalid string from server!"; + qWarning() << "Received invalid string from server!"; return; } foo = serverDecode(params.takeFirst()); @@ -92,7 +92,7 @@ void IrcServerHandler::handleServerMsg(QByteArray msg) { uint num = cmd.toUInt(); if(num > 0) { if(params.count() == 0) { - quWarning() << "Message received from server violates RFC and is ignored!"; + qWarning() << "Message received from server violates RFC and is ignored!"; return; } params.removeFirst(); @@ -244,7 +244,7 @@ void IrcServerHandler::handleMode(const QString &prefix, const QList else channel->removeUserMode(ircUser, QString(modes[c])); } else { - quWarning() << "Received MODE with too few parameters:" << serverDecode(params); + qWarning() << "Received MODE with too few parameters:" << serverDecode(params); } paramOffset++; } else { @@ -255,7 +255,7 @@ void IrcServerHandler::handleMode(const QString &prefix, const QList if(paramOffset < params.count()) { value = params[paramOffset]; } else { - quWarning() << "Received MODE with too few parameters:" << serverDecode(params); + qWarning() << "Received MODE with too few parameters:" << serverDecode(params); } paramOffset++; } @@ -304,7 +304,7 @@ void IrcServerHandler::handleNick(const QString &prefix, const QList IrcUser *ircuser = network()->updateNickFromMask(prefix); if(!ircuser) { - quWarning() << "IrcServerHandler::handleNick(): Unknown IrcUser!"; + qWarning() << "IrcServerHandler::handleNick(): Unknown IrcUser!"; return; } QString newnick = serverDecode(params[0]); @@ -341,7 +341,7 @@ void IrcServerHandler::handlePart(const QString &prefix, const QList IrcUser *ircuser = network()->updateNickFromMask(prefix); QString channel = serverDecode(params[0]); if(!ircuser) { - quWarning() << "IrcServerHandler::handlePart(): Unknown IrcUser!"; + qWarning() << "IrcServerHandler::handlePart(): Unknown IrcUser!"; return; } @@ -383,12 +383,12 @@ void IrcServerHandler::handlePrivmsg(const QString &prefix, const QListupdateNickFromMask(prefix); if(!ircuser) { - quWarning() << "IrcServerHandler::handlePrivmsg(): Unknown IrcUser!"; + qWarning() << "IrcServerHandler::handlePrivmsg(): Unknown IrcUser!"; return; } if(params.isEmpty()) { - quWarning() << "IrcServerHandler::handlePrivmsg(): received PRIVMSG without target or message from:" << prefix; + qWarning() << "IrcServerHandler::handlePrivmsg(): received PRIVMSG without target or message from:" << prefix; return; } @@ -879,7 +879,7 @@ void IrcServerHandler::handle353(const QString &prefix, const QList IrcChannel *channel = network()->ircChannel(channelname); if(!channel) { - quWarning() << "IrcServerHandler::handle353(): received unknown target channel:" << channelname; + qWarning() << "IrcServerHandler::handle353(): received unknown target channel:" << channelname; return; } @@ -963,7 +963,7 @@ void IrcServerHandler::tryNextNick(const QString &errnick) { bool IrcServerHandler::checkParamCount(const QString &methodName, const QList ¶ms, int minParams) { if(params.count() < minParams) { - quWarning() << qPrintable(methodName) << "requires" << minParams << "parameters but received only" << params.count() << serverDecode(params); + qWarning() << qPrintable(methodName) << "requires" << minParams << "parameters but received only" << params.count() << serverDecode(params); return false; } else { return true; diff --git a/src/core/networkconnection.cpp b/src/core/networkconnection.cpp index 5815a910..5d279655 100644 --- a/src/core/networkconnection.cpp +++ b/src/core/networkconnection.cpp @@ -179,11 +179,11 @@ void NetworkConnection::connectToIrc(bool reconnecting) { QVariantList serverList = network()->serverList(); Identity *identity = coreSession()->identity(network()->identity()); if(!serverList.count()) { - quWarning() << "Server list empty, ignoring connect request!"; + qWarning() << "Server list empty, ignoring connect request!"; return; } if(!identity) { - quWarning() << "Invalid identity configures, ignoring connect request!"; + qWarning() << "Invalid identity configures, ignoring connect request!"; return; } // use a random server? @@ -278,7 +278,7 @@ void NetworkConnection::socketHasData() { void NetworkConnection::socketError(QAbstractSocket::SocketError) { _previousConnectionAttemptFailed = true; - quWarning() << qPrintable(tr("Could not connect to %1 (%2)").arg(network()->networkName(), socket.errorString())); + qWarning() << 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()); @@ -335,7 +335,7 @@ void NetworkConnection::socketInitialized() { //emit connected(networkId()); initialize first! Identity *identity = coreSession()->identity(network()->identity()); if(!identity) { - quError() << "Identity invalid!"; + qCritical() << "Identity invalid!"; disconnectFromIrc(); return; } @@ -398,7 +398,7 @@ void NetworkConnection::socketDisconnected() { void NetworkConnection::doAutoReconnect() { if(connectionState() != Network::Disconnected && connectionState() != Network::Reconnecting) { - quWarning() << "NetworkConnection::doAutoReconnect(): Cannot reconnect while not being disconnected!"; + qWarning() << "NetworkConnection::doAutoReconnect(): Cannot reconnect while not being disconnected!"; return; } if(_autoReconnectCount > 0) _autoReconnectCount--; diff --git a/src/core/sqlitestorage.cpp b/src/core/sqlitestorage.cpp index 7c46333d..ef510e7c 100644 --- a/src/core/sqlitestorage.cpp +++ b/src/core/sqlitestorage.cpp @@ -269,7 +269,7 @@ bool SqliteStorage::removeNetwork(UserId user, const NetworkId &networkId) { if(withTransaction) { sync(); if(!logDb().transaction()) { - quWarning() << "SqliteStorage::removeNetwork(): cannot start transaction. continuing with out rollback support!"; + qWarning() << "SqliteStorage::removeNetwork(): cannot start transaction. continuing with out rollback support!"; withTransaction = false; } } @@ -503,19 +503,19 @@ BufferInfo SqliteStorage::getBufferInfo(UserId user, const NetworkId &networkId, query->exec(); if(!query->first()) { watchQuery(query); - quWarning() << "unable to create BufferInfo for:" << user << networkId << buffer; + qWarning() << "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()) { - quError() << "SqliteStorage::getBufferInfo(): received more then one Buffer!"; - quError() << " Query:" << query->lastQuery(); - quError() << " bound Values:"; + qCritical() << "SqliteStorage::getBufferInfo(): received more then one Buffer!"; + qCritical() << " Query:" << query->lastQuery(); + qCritical() << " bound Values:"; QList list = query->boundValues().values(); for (int i = 0; i < list.size(); ++i) - quError() << i << ":" << list.at(i).toString().toAscii().data(); + qCritical() << i << ":" << list.at(i).toString().toAscii().data(); Q_ASSERT(false); } @@ -825,7 +825,7 @@ bool SqliteStorage::init(const QVariantMap &settings) { getPasswordsQuery.exec(); if(!watchQuery(&getPasswordsQuery)) { - quError() << "unable to migrate to new password format!"; + qCritical() << "unable to migrate to new password format!"; return false; } @@ -843,6 +843,6 @@ bool SqliteStorage::init(const QVariantMap &settings) { watchQuery(&setPasswordsQuery); } - quDebug() << "successfully migrated passwords!"; + qDebug() << "successfully migrated passwords!"; return true; } diff --git a/src/core/sslserver.cpp b/src/core/sslserver.cpp index c94859ed..c7e1b351 100644 --- a/src/core/sslserver.cpp +++ b/src/core/sslserver.cpp @@ -46,7 +46,7 @@ SslServer::SslServer(QObject *parent) _certIsValid = !_cert.isNull() && _cert.isValid() && !_key.isNull(); if(!_certIsValid) { - quWarning() << "SslServer: SSL Certificate is either missing or has a wrong format!\n" + qWarning() << "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."; } diff --git a/src/qtui/CMakeLists.txt b/src/qtui/CMakeLists.txt index 35bda869..4a591267 100644 --- a/src/qtui/CMakeLists.txt +++ b/src/qtui/CMakeLists.txt @@ -25,6 +25,7 @@ set(SOURCES coreconnectdlg.cpp coreinfodlg.cpp debugconsole.cpp + debuglogwidget.cpp inputwidget.cpp jumpkeyhandler.cpp mainwin.cpp @@ -62,6 +63,7 @@ set(MOC_HDRS coreconnectdlg.h coreinfodlg.h debugconsole.h + debuglogwidget.h inputwidget.h jumpkeyhandler.h mainwin.h @@ -102,6 +104,7 @@ set(FORMS coreconnectdlg.ui coreinfodlg.ui debugconsole.ui + debuglogwidget.ui inputwidget.ui msgprocessorstatuswidget.ui nicklistwidget.ui diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 1f701f56..e7390ea5 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -34,6 +34,7 @@ #include "clientbacklogmanager.h" #include "coreinfodlg.h" #include "coreconnectdlg.h" +#include "debuglogwidget.h" #include "iconloader.h" #include "inputwidget.h" #include "inputline.h" @@ -197,6 +198,8 @@ void MainWin::setupActions() { qApp, SLOT(aboutQt()))); coll->addAction("DebugNetworkModel", new Action(SmallIcon("tools-report-bug"), tr("Debug &NetworkModel"), coll, this, SLOT(on_actionDebugNetworkModel_triggered()))); + coll->addAction("DebugLog", new Action(SmallIcon("tools-report-bug"), tr("Debug &Log"), coll, + this, SLOT(on_actionDebugLog_triggered()))); } void MainWin::setupMenus() { @@ -231,6 +234,7 @@ void MainWin::setupMenus() { _helpMenu->addSeparator(); _helpDebugMenu = _helpMenu->addMenu(SmallIcon("tools-report-bug"), tr("Debug")); _helpDebugMenu->addAction(coll->action("DebugNetworkModel")); + _helpDebugMenu->addAction(coll->action("DebugLog")); } void MainWin::setupBufferWidget() { @@ -733,6 +737,11 @@ void MainWin::on_actionDebugNetworkModel_triggered() { view->show(); } +void MainWin::on_actionDebugLog_triggered() { + DebugLogWidget *logWidget = new DebugLogWidget(0); + logWidget->show(); +} + void MainWin::saveStateToSession(const QString &sessionId) { return; SessionSettings s(sessionId); diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index 74953c09..a2d0bc8b 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -84,6 +84,7 @@ class MainWin : public QMainWindow { void on_actionManageViews_triggered(); void on_actionLockDockPositions_toggled(bool lock); void on_actionDebugNetworkModel_triggered(); + void on_actionDebugLog_triggered(); void clientNetworkCreated(NetworkId); void clientNetworkRemoved(NetworkId); diff --git a/src/qtui/qtuiapplication.cpp b/src/qtui/qtuiapplication.cpp index 7a6f0977..90e2739d 100644 --- a/src/qtui/qtuiapplication.cpp +++ b/src/qtui/qtuiapplication.cpp @@ -27,13 +27,36 @@ #include "qtui.h" #include "sessionsettings.h" -QtUiApplication::QtUiApplication(int &argc, char **argv) : QApplication(argc, argv), Quassel() { + +// void myMessageOutput(QtMsgType type, const char *msg) { +// Client::debugLog() << "Debug:" << msg << '\n'; +// return; +// // switch (type) { +// // case QtDebugMsg: +// // break; +// // case QtWarningMsg: +// // fprintf(stderr, "Warning: %s\n", msg); +// // break; +// // case QtCriticalMsg: +// // fprintf(stderr, "Critical: %s\n", msg); +// // break; +// // case QtFatalMsg: +// // fprintf(stderr, "Fatal: %s\n", msg); +// // abort(); +// // } +// } + +QtUiApplication::QtUiApplication(int &argc, char **argv) + : QApplication(argc, argv), Quassel() +{ setRunMode(Quassel::ClientOnly); // put client-only arguments here CliParser *parser = Quassel::cliParser(); parser->addSwitch("debugbufferswitches",0,"Enables debugging for bufferswitches"); parser->addSwitch("debugmodel",0,"Enables debugging for models"); + + qInstallMsgHandler(Client::logMessage); } bool QtUiApplication::init() { @@ -79,3 +102,5 @@ void QtUiApplication::resumeSessionIfPossible() { s.cleanup(); } } + + diff --git a/src/qtui/qtuiapplication.h b/src/qtui/qtuiapplication.h index f46f3a78..9fb572ab 100644 --- a/src/qtui/qtuiapplication.h +++ b/src/qtui/qtuiapplication.h @@ -32,20 +32,19 @@ class QtUi; class QtUiApplication : public QApplication, public Quassel { Q_OBJECT - public: - QtUiApplication(int &, char **); - ~QtUiApplication(); - virtual bool init(); - - void resumeSessionIfPossible(); - virtual void saveState(QSessionManager & manager); - - signals: - void saveStateToSession(const QString &sessionId); - void saveStateToSessionSettings(SessionSettings &s); // FIXME refs in signals won't probably work - void resumeFromSession(const QString sessionId); - void resumeFromSessionSettings(SessionSettings &s); - + public: + QtUiApplication(int &, char **); + ~QtUiApplication(); + virtual bool init(); + + void resumeSessionIfPossible(); + virtual void saveState(QSessionManager & manager); + +signals: + void saveStateToSession(const QString &sessionId); + void saveStateToSessionSettings(SessionSettings &s); // FIXME refs in signals won't probably work + void resumeFromSession(const QString sessionId); + void resumeFromSessionSettings(SessionSettings &s); }; #endif