diff --git a/YACReaderLibrary/main.cpp b/YACReaderLibrary/main.cpp index 3216e7db..33b1a97b 100644 --- a/YACReaderLibrary/main.cpp +++ b/YACReaderLibrary/main.cpp @@ -11,8 +11,11 @@ #if QT_VERSION >= 0x050000 #include +#else +#include #endif + #include "yacreader_global.h" #include "startup.h" #include "yacreader_local_server.h" @@ -50,9 +53,32 @@ void yacreaderMessageHandler(QtMsgType type, const QMessageLogContext &context, ts << QDateTime::currentDateTime().toString() << " - " << txt << endl; } #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