StelLogger.cpp   StelLogger.cpp 
skipping to change at line 21 skipping to change at line 21
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "StelLogger.hpp" #include "StelLogger.hpp"
#include "StelUtils.hpp"
#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;
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))
qInstallMsgHandler(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)));
// write info about operating system
writeLog(StelUtils::getOperatingSystemInfo());
// write OS version // write compiler version
#ifdef Q_OS_WIN
switch(QSysInfo::WindowsVersion)
{
case QSysInfo::WV_95:
writeLog("Windows 95");
break;
case QSysInfo::WV_98:
writeLog("Windows 98");
break;
case QSysInfo::WV_Me:
writeLog("Windows Me");
break;
case QSysInfo::WV_NT:
writeLog("Windows NT");
break;
case QSysInfo::WV_2000:
writeLog("Windows 2000");
break;
case QSysInfo::WV_XP:
writeLog("Windows XP");
break;
case QSysInfo::WV_2003:
writeLog("Windows Server 2003");
break;
case QSysInfo::WV_VISTA:
writeLog("Windows Vista");
break;
case QSysInfo::WV_WINDOWS7:
writeLog("Windows 7");
break;
#ifdef WV_WINDOWS8
case QSysInfo::WV_WINDOWS8:
writeLog("Windows 8");
break;
#endif
default:
writeLog("Unsupported Windows version");
break;
}
// somebody writing something useful for Macs would be great here
#elif defined Q_OS_MAC
switch(QSysInfo::MacintoshVersion)
{
case QSysInfo::MV_10_3:
writeLog("Mac OS X 10.3");
break;
case QSysInfo::MV_10_4:
writeLog("Mac OS X 10.4");
break;
case QSysInfo::MV_10_5:
writeLog("Mac OS X 10.5");
break;
case QSysInfo::MV_10_6:
writeLog("Mac OS X 10.6");
break;
#ifdef MV_10_7
case QSysInfo::MV_10_7:
writeLog("Mac OS X 10.7");
break;
#endif
#ifdef MV_10_8
case QSysInfo::MV_10_8:
writeLog("Mac OS X 10.8");
break;
#endif
default:
writeLog("Unsupported Mac version");
break;
}
#elif defined Q_OS_LINUX
QFile procVersion("/proc/version");
if(!procVersion.open(QIODevice::ReadOnly | QIODevice::Text))
writeLog("Unknown Linux version");
else
{
QString version = procVersion.readAll();
if(version.right(1) == "\n")
version.chop(1);
writeLog(version);
procVersion.close();
}
#elif defined Q_OS_BSD4
// Check FreeBSD, NetBSD, OpenBSD and DragonFly BSD
QProcess uname;
uname.start("/usr/bin/uname -srm");
uname.waitForStarted();
uname.waitForFinished();
const QString BSDsystem = uname.readAllStandardOutput();
writeLog(BSDsystem.trimmed());
#else
writeLog("Unknown operating system");
#endif
// write GCC version
#if defined __GNUC__ && !defined __clang__ #if defined __GNUC__ && !defined __clang__
#ifdef __MINGW32__ #ifdef __MINGW32__
#define COMPILER "MinGW GCC" #define COMPILER "MinGW GCC"
#else #else
#define COMPILER "GCC" #define COMPILER "GCC"
#endif #endif
writeLog(QString("Compiled using %1 %2.%3.%4").arg(COMPILER).arg(__G NUC__).arg(__GNUC_MINOR__).arg(__GNUC_PATCHLEVEL__)); writeLog(QString("Compiled using %1 %2.%3.%4").arg(COMPILER).arg(__G NUC__).arg(__GNUC_MINOR__).arg(__GNUC_PATCHLEVEL__));
#elif defined __clang__ #elif defined __clang__
writeLog(QString("Compiled using %1 %2.%3.%4").arg("Clang").arg(__cl ang_major__).arg(__clang_minor__).arg(__clang_patchlevel__)); writeLog(QString("Compiled using %1 %2.%3.%4").arg("Clang").arg(__cl ang_major__).arg(__clang_minor__).arg(__clang_patchlevel__));
#elif defined _MSC_VER
writeLog(QString("Compiled using %1").arg(getMsvcVersionString(_MSC_
VER)));
#else #else
writeLog("Unknown compiler"); writeLog("Unknown compiler");
#endif #endif
// write Qt version // write Qt version
writeLog(QString("Qt runtime version: %1").arg(qVersion())); writeLog(QString("Qt runtime version: %1").arg(qVersion()));
writeLog(QString("Qt compilation version: %1").arg(QT_VERSION_STR)); writeLog(QString("Qt compilation version: %1").arg(QT_VERSION_STR));
// write addressing mode // write addressing mode
#if defined(__LP64__) || defined(_WIN64) #if defined(__LP64__) || defined(_WIN64)
skipping to change at line 343 skipping to change at line 252
{ {
writeLog(dmesgLines.at(i).trimmed()); writeLog(dmesgLines.at(i).trimmed());
} }
} }
#endif #endif
} }
void StelLogger::deinit() void StelLogger::deinit()
{ {
qInstallMsgHandler(0); qInstallMessageHandler(0);
logFile.close(); logFile.close();
} }
void StelLogger::debugLogHandler(QtMsgType, const char* msg) void StelLogger::debugLogHandler(QtMsgType, const QMessageLogContext&, cons t QString& msg)
{ {
fprintf(stderr, "%s\n", msg); fprintf(stderr, "%s\n", msg.toUtf8().constData());
writeLog(QString(msg)); writeLog(QString(msg));
} }
void StelLogger::writeLog(QString msg) void StelLogger::writeLog(QString msg)
{ {
msg += "\n"; msg += "\n";
logFile.write(qPrintable(msg), msg.size()); logFile.write(qPrintable(msg), msg.size());
log += msg; log += msg;
} }
QString StelLogger::getMsvcVersionString(int ver)
{
QString version;
switch(ver)
{
case 1310:
version = "MSVC++ 7.1 (Visual Studio 2003)";
break;
case 1400:
version = "MSVC++ 8.0 (Visual Studio 2005)";
break;
case 1500:
version = "MSVC++ 9.0 (Visual Studio 2008)";
break;
case 1600:
version = "MSVC++ 10.0 (Visual Studio 2010)";
break;
case 1700:
version = "MSVC++ 11.0 (Visual Studio 2012)";
break;
case 1800:
version = "MSVC++ 12.0 (Visual Studio 2013)";
break;
default:
version = "unknown MSVC++ version";
}
return version;
}
 End of changes. 9 change blocks. 
101 lines changed or deleted 11 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/