StelLogger.cpp   StelLogger.cpp 
skipping to change at line 32 skipping to change at line 32
#include <QDateTime> #include <QDateTime>
#include <QProcess> #include <QProcess>
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include <windows.h> #include <windows.h>
#endif #endif
// Init statics variables. // Init statics variables.
QFile StelLogger::logFile; QFile StelLogger::logFile;
QString StelLogger::log; QString StelLogger::log;
QMutex StelLogger::fileMutex;
void StelLogger::init(const QString& logFilePath) void StelLogger::init(const QString& logFilePath)
{ {
logFile.setFileName(logFilePath); logFile.setFileName(logFilePath);
if (logFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODev ice::Text | QIODevice::Unbuffered)) if (logFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODev ice::Text | QIODevice::Unbuffered))
qInstallMessageHandler(StelLogger::debugLogHandler); qInstallMessageHandler(StelLogger::debugLogHandler);
// write timestamp // write timestamp
writeLog(QString("%1").arg(QDateTime::currentDateTime().toString(Qt: :ISODate))); writeLog(QString("%1").arg(QDateTime::currentDateTime().toString(Qt: :ISODate)));
skipping to change at line 254 skipping to change at line 255
#endif #endif
} }
void StelLogger::deinit() void StelLogger::deinit()
{ {
qInstallMessageHandler(0); qInstallMessageHandler(0);
logFile.close(); logFile.close();
} }
void StelLogger::debugLogHandler(QtMsgType, const QMessageLogContext&, cons t QString& msg) void StelLogger::debugLogHandler(QtMsgType type, const QMessageLogContext& ctx, const QString& msg)
{ {
fprintf(stderr, "%s\n", msg.toUtf8().constData()); #if (QT_VERSION>=QT_VERSION_CHECK(5,4,0))
writeLog(QString(msg)); //use Qt to format the log message, if possible
//this uses the format set by qSetMessagePattern
//or QT_MESSAGE_PATTERN environment var
QString fmt = qFormatLogMessage(type,ctx,msg);
#else
Q_UNUSED(type)
Q_UNUSED(ctx)
QString fmt = msg;
#endif
//do nothing for null messages
if(fmt.isNull())
return;
#ifdef Q_OS_WIN
//Send debug messages to Debugger, if one is attached, instead of st
derr
//This seems to avoid output delays in Qt Creator, allowing for easi
er debugging
//Seems to work fine with MSVC and MinGW
if(IsDebuggerPresent())
OutputDebugStringW(reinterpret_cast<LPCWSTR>(fmt.utf16()));
else
#endif
//this does the same as the default handler in qlogging.cpp
fprintf(stderr, "%s\n", qPrintable(fmt));
fflush(stderr);
writeLog(fmt);
} }
void StelLogger::writeLog(QString msg) void StelLogger::writeLog(QString msg)
{ {
fileMutex.lock();
msg += "\n"; msg += "\n";
logFile.write(qPrintable(msg), msg.size()); logFile.write(qPrintable(msg), msg.size());
log += msg; log += msg;
fileMutex.unlock();
} }
QString StelLogger::getMsvcVersionString(int ver) QString StelLogger::getMsvcVersionString(int ver)
{ {
QString version; QString version;
switch(ver) switch(ver)
{ {
case 1310: case 1310:
version = "MSVC++ 7.1 (Visual Studio 2003)"; version = "MSVC++ 7.1 (Visual Studio 2003)";
break; break;
skipping to change at line 290 skipping to change at line 317
break; break;
case 1600: case 1600:
version = "MSVC++ 10.0 (Visual Studio 2010)"; version = "MSVC++ 10.0 (Visual Studio 2010)";
break; break;
case 1700: case 1700:
version = "MSVC++ 11.0 (Visual Studio 2012)"; version = "MSVC++ 11.0 (Visual Studio 2012)";
break; break;
case 1800: case 1800:
version = "MSVC++ 12.0 (Visual Studio 2013)"; version = "MSVC++ 12.0 (Visual Studio 2013)";
break; break;
case 1900:
version = "MSVC++ 14.0 (Visual Studio 2015)";
break;
default: default:
version = "unknown MSVC++ version"; version = "unknown MSVC++ version";
} }
return version; return version;
} }
 End of changes. 6 change blocks. 
3 lines changed or deleted 35 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/