}
+#if QT_VERSION < 0x050000
void Client::logMessage(QtMsgType type, const char *msg)
{
fprintf(stderr, "%s\n", msg);
emit instance()->logUpdated(msgString);
}
}
+#else
+void Client::logMessage(QtMsgType type, const QMessageLogContext &context, const QString &msg)
+{
+ Q_UNUSED(context);
+
+ fprintf(stderr, "%s\n", msg.toLocal8Bit().constData());
+ fflush(stderr);
+ if (type == QtFatalMsg) {
+ Quassel::logFatalMessage(msg.toLocal8Bit().constData());
+ }
+ else {
+ QString msgString = QString("%1\n").arg(msg);
+
+ //Check to see if there is an instance around, else we risk recursions
+ //when calling instance() and creating new ones.
+ if (!instanceExists())
+ return;
+
+ instance()->_debugLog << msgString;
+ emit instance()->logUpdated(msgString);
+ }
+}
+#endif
static void mergeBuffersPermanently(BufferId bufferId1, BufferId bufferId2);
static void purgeKnownBufferIds();
+#if QT_VERSION < 0x050000
static void logMessage(QtMsgType type, const char *msg);
+#else
+ static void logMessage(QtMsgType, const QMessageLogContext&, const QString&);
+#endif
static inline const QString &debugLog() { return instance()->_debugLogBuffer; }
signals:
}
+#if QT_VERSION < 0x050000
void Logger::logMessage(QtMsgType type, const char *msg)
{
switch (type) {
return;
}
}
+#else
+void Logger::logMessage(QtMsgType type, const QMessageLogContext &context, const QString &msg)
+{
+ Q_UNUSED(context)
+
+ switch (type) {
+ case QtDebugMsg:
+ Logger(Quassel::DebugLevel) << msg.toLocal8Bit().constData();
+ break;
+ case QtWarningMsg:
+ Logger(Quassel::WarningLevel) << msg.toLocal8Bit().constData();
+ break;
+ case QtCriticalMsg:
+ Logger(Quassel::ErrorLevel) << msg.toLocal8Bit().constData();
+ break;
+ case QtFatalMsg:
+ Logger(Quassel::ErrorLevel) << msg.toLocal8Bit().constData();
+ Quassel::logFatalMessage(msg.toLocal8Bit().constData());
+ return;
+ }
+}
+#endif
inline Logger(Quassel::LogLevel level) : _stream(&_buffer, QIODevice::WriteOnly), _logLevel(level) {}
~Logger();
+#if QT_VERSION < 0x050000
static void logMessage(QtMsgType type, const char *msg);
+#else
+ static void logMessage(QtMsgType, const QMessageLogContext&, const QString&);
+#endif
template<typename T>
inline Logger &operator<<(const T &value) { _stream << value << " "; return *this; }
bool CoreApplication::init()
{
if (Quassel::init() && _internal->init()) {
+#if QT_VERSION < 0x050000
qInstallMsgHandler(Logger::logMessage);
+#else
+ qInstallMessageHandler(Logger::logMessage);
+#endif
return true;
}
return false;
#endif /* HAVE_KDE || Q_OS_MAC */
setRunMode(Quassel::ClientOnly);
+#if QT_VERSION < 0x050000
qInstallMsgHandler(Client::logMessage);
+#else
+ qInstallMessageHandler(Client::logMessage);
+#endif
}