Add comp architecture (#2968)

This commit is contained in:
Kyle Grammer 2018-01-10 22:19:08 -05:00 committed by Zach H
parent c8122c94ef
commit 6fc1aaef90
4 changed files with 83 additions and 33 deletions

View file

@ -55,4 +55,5 @@ void DlgViewLog::closeEvent(QCloseEvent * /* event */)
} }
logArea->appendPlainText(Logger::getInstance().getClientVersion()); logArea->appendPlainText(Logger::getInstance().getClientVersion());
logArea->appendPlainText(Logger::getInstance().getSystemArchitecture());
} }

View file

@ -6,10 +6,16 @@
#define LOGGER_MAX_ENTRIES 128 #define LOGGER_MAX_ENTRIES 128
#define LOGGER_FILENAME "qdebug.txt" #define LOGGER_FILENAME "qdebug.txt"
#if QT_VERSION >= 0x050400
#include <QSysInfo>
#endif
Logger::Logger() : logToFileEnabled(false) Logger::Logger() : logToFileEnabled(false)
{ {
logBuffer.append(getClientVersion()); logBuffer.append(getClientVersion());
logBuffer.append(getSystemArchitecture());
std::cerr << getClientVersion().toStdString() << std::endl; std::cerr << getClientVersion().toStdString() << std::endl;
std::cerr << getSystemArchitecture().toStdString() << std::endl;
} }
Logger::~Logger() Logger::~Logger()
@ -47,6 +53,7 @@ void Logger::openLogfileSession()
fileStream.setDevice(&fileHandle); fileStream.setDevice(&fileHandle);
fileStream << "Log session started at " << QDateTime::currentDateTime().toString() << endl; fileStream << "Log session started at " << QDateTime::currentDateTime().toString() << endl;
fileStream << getClientVersion() << endl; fileStream << getClientVersion() << endl;
fileStream << getSystemArchitecture() << endl;
logToFileEnabled = true; logToFileEnabled = true;
} }
@ -81,3 +88,27 @@ void Logger::internalLog(const QString message)
if (logToFileEnabled) if (logToFileEnabled)
fileStream << message << endl; // Print to fileStream fileStream << message << endl; // Print to fileStream
} }
QString Logger::getSystemArchitecture()
{
QString result;
if (!getClientOperatingSystem().isEmpty())
{
result.append(tr("Client Operating System") + ": " + getClientOperatingSystem() + "\n");
}
result.append(tr("Build Architecture") + ": " + QString::fromStdString(BUILD_ARCHITECTURE) + "\n");
result.append(tr("Qt Version") + ": " + QT_VERSION_STR);
return result;
}
QString Logger::getClientOperatingSystem()
{
#ifdef QSYSINFO_H
return QSysInfo::prettyProductName();
#endif
return {};
}

View file

@ -7,15 +7,34 @@
#include <QString> #include <QString>
#include <QMutex> #include <QMutex>
class Logger : public QObject { #if defined(Q_PROCESSOR_X86_32)
Q_OBJECT #define BUILD_ARCHITECTURE "32-bit"
public: #elif defined(Q_PROCESSOR_X86_64)
#define BUILD_ARCHITECTURE "64-bit"
#elif defined(Q_PROCESSOR_ARM)
#define BUILD_ARCHITECTURE "ARM"
#else
#define BUILD_ARCHITECTURE "unknown"
#endif
class Logger : public QObject
{
Q_OBJECT
public:
static Logger& getInstance() static Logger& getInstance()
{ {
static Logger instance; static Logger instance;
return instance; return instance;
} }
private:
void logToFile(bool enabled);
void log(QtMsgType type, const QMessageLogContext &ctx, const QString message);
QString getClientVersion();
QString getClientOperatingSystem();
QString getSystemArchitecture();
QList<QString> getLogBuffer() { return logBuffer; }
private:
Logger(); Logger();
~Logger(); ~Logger();
// Singleton - Don't implement copy constructor and assign operator // Singleton - Don't implement copy constructor and assign operator
@ -27,17 +46,15 @@ private:
QFile fileHandle; QFile fileHandle;
QList<QString> logBuffer; QList<QString> logBuffer;
QMutex mutex; QMutex mutex;
public:
void logToFile(bool enabled); protected:
void log(QtMsgType type, const QMessageLogContext &ctx, const QString message);
QString getClientVersion();
QList<QString> getLogBuffer() { return logBuffer; }
protected:
void openLogfileSession(); void openLogfileSession();
void closeLogfileSession(); void closeLogfileSession();
protected slots:
protected slots:
void internalLog(const QString message); void internalLog(const QString message);
signals:
signals:
void logEntryAdded(QString message); void logEntryAdded(QString message);
}; };

View file

@ -48,6 +48,7 @@
#include "localserver.h" #include "localserver.h"
#include "localserverinterface.h" #include "localserverinterface.h"
#include "localclient.h" #include "localclient.h"
#include "logger.h"
#include "settingscache.h" #include "settingscache.h"
#include "tab_game.h" #include "tab_game.h"
#include "version_string.h" #include "version_string.h"
@ -282,7 +283,7 @@ void MainWindow::actExit()
void MainWindow::actAbout() void MainWindow::actAbout()
{ {
QMessageBox mb(QMessageBox::NoIcon, tr("About Cockatrice"), QString( QMessageBox mb(QMessageBox::NoIcon, tr("About Cockatrice"), QString(
"<font size=\"8\"><b>Cockatrice</b></font><br>" "<font size=\"8\"><b>Cockatrice</b></font> (" + QString::fromStdString(BUILD_ARCHITECTURE) + ")<br>"
+ tr("Version") + QString(" %1").arg(VERSION_STRING) + tr("Version") + QString(" %1").arg(VERSION_STRING)
+ "<br><br><b><a href='" + GITHUB_PAGES_URL + "'>" + tr("Cockatrice Webpage") + "</a></b><br>" + "<br><br><b><a href='" + GITHUB_PAGES_URL + "'>" + tr("Cockatrice Webpage") + "</a></b><br>"
+ "<br><br><b>" + tr("Project Manager:") + "</b><br>Gavin Bisesi<br><br>" + "<br><br><b>" + tr("Project Manager:") + "</b><br>Gavin Bisesi<br><br>"