Add comp architecture (#2968)
This commit is contained in:
parent
c8122c94ef
commit
6fc1aaef90
4 changed files with 83 additions and 33 deletions
|
@ -55,4 +55,5 @@ void DlgViewLog::closeEvent(QCloseEvent * /* event */)
|
||||||
}
|
}
|
||||||
|
|
||||||
logArea->appendPlainText(Logger::getInstance().getClientVersion());
|
logArea->appendPlainText(Logger::getInstance().getClientVersion());
|
||||||
}
|
logArea->appendPlainText(Logger::getInstance().getSystemArchitecture());
|
||||||
|
}
|
||||||
|
|
|
@ -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 {};
|
||||||
|
}
|
||||||
|
|
|
@ -7,38 +7,55 @@
|
||||||
#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)
|
||||||
static Logger& getInstance()
|
#define BUILD_ARCHITECTURE "64-bit"
|
||||||
{
|
#elif defined(Q_PROCESSOR_ARM)
|
||||||
static Logger instance;
|
#define BUILD_ARCHITECTURE "ARM"
|
||||||
return instance;
|
#else
|
||||||
}
|
#define BUILD_ARCHITECTURE "unknown"
|
||||||
private:
|
#endif
|
||||||
Logger();
|
|
||||||
~Logger();
|
|
||||||
// Singleton - Don't implement copy constructor and assign operator
|
|
||||||
Logger(Logger const&);
|
|
||||||
void operator=(Logger const&);
|
|
||||||
|
|
||||||
bool logToFileEnabled;
|
class Logger : public QObject
|
||||||
QTextStream fileStream;
|
{
|
||||||
QFile fileHandle;
|
Q_OBJECT
|
||||||
QList<QString> logBuffer;
|
public:
|
||||||
QMutex mutex;
|
static Logger& getInstance()
|
||||||
public:
|
{
|
||||||
void logToFile(bool enabled);
|
static Logger instance;
|
||||||
void log(QtMsgType type, const QMessageLogContext &ctx, const QString message);
|
return instance;
|
||||||
QString getClientVersion();
|
}
|
||||||
QList<QString> getLogBuffer() { return logBuffer; }
|
|
||||||
protected:
|
void logToFile(bool enabled);
|
||||||
void openLogfileSession();
|
void log(QtMsgType type, const QMessageLogContext &ctx, const QString message);
|
||||||
void closeLogfileSession();
|
QString getClientVersion();
|
||||||
protected slots:
|
QString getClientOperatingSystem();
|
||||||
void internalLog(const QString message);
|
QString getSystemArchitecture();
|
||||||
signals:
|
QList<QString> getLogBuffer() { return logBuffer; }
|
||||||
void logEntryAdded(QString message);
|
|
||||||
|
private:
|
||||||
|
Logger();
|
||||||
|
~Logger();
|
||||||
|
// Singleton - Don't implement copy constructor and assign operator
|
||||||
|
Logger(Logger const&);
|
||||||
|
void operator=(Logger const&);
|
||||||
|
|
||||||
|
bool logToFileEnabled;
|
||||||
|
QTextStream fileStream;
|
||||||
|
QFile fileHandle;
|
||||||
|
QList<QString> logBuffer;
|
||||||
|
QMutex mutex;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void openLogfileSession();
|
||||||
|
void closeLogfileSession();
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void internalLog(const QString message);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void logEntryAdded(QString message);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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>"
|
||||||
|
|
Loading…
Reference in a new issue