mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
added message handler for Qt4
This commit is contained in:
parent
944318b63e
commit
9db62a6475
@ -11,8 +11,11 @@
|
|||||||
|
|
||||||
#if QT_VERSION >= 0x050000
|
#if QT_VERSION >= 0x050000
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
#else
|
||||||
|
#include <QDesktopServices>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "yacreader_global.h"
|
#include "yacreader_global.h"
|
||||||
#include "startup.h"
|
#include "startup.h"
|
||||||
#include "yacreader_local_server.h"
|
#include "yacreader_local_server.h"
|
||||||
@ -50,9 +53,32 @@ void yacreaderMessageHandler(QtMsgType type, const QMessageLogContext &context,
|
|||||||
ts << QDateTime::currentDateTime().toString() << " - " << txt << endl;
|
ts << QDateTime::currentDateTime().toString() << " - " << txt << endl;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void yacreaderMessageHandler(QtMsgType type, const char *)
|
void yacreaderMessageHandler(QtMsgType type, const char * msg)
|
||||||
{
|
{
|
||||||
|
QString txt;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case QtDebugMsg:
|
||||||
|
txt = QString("Debug: %1").arg(msg);
|
||||||
|
break;
|
||||||
|
case QtWarningMsg:
|
||||||
|
txt = QString("Warning: %1").arg(msg);
|
||||||
|
break;
|
||||||
|
case QtCriticalMsg:
|
||||||
|
txt = QString("Critical: %1").arg(msg);
|
||||||
|
break;
|
||||||
|
case QtFatalMsg:
|
||||||
|
txt = QString("Fatal: %1").arg(msg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDir().mkpath(QDesktopServices::storageLocation(QDesktopServices::DataLocation));
|
||||||
|
|
||||||
|
QFile outFile(QDesktopServices::storageLocation(QDesktopServices::DataLocation)+"/yacreaderlibrary.log");
|
||||||
|
|
||||||
|
outFile.open(QIODevice::WriteOnly | QIODevice::Append);
|
||||||
|
QTextStream ts(&outFile);
|
||||||
|
ts << QDateTime::currentDateTime().toString() << " - " << txt << endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user