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().getSystemArchitecture());
|
||||
}
|
||||
|
|
|
@ -6,10 +6,16 @@
|
|||
#define LOGGER_MAX_ENTRIES 128
|
||||
#define LOGGER_FILENAME "qdebug.txt"
|
||||
|
||||
#if QT_VERSION >= 0x050400
|
||||
#include <QSysInfo>
|
||||
#endif
|
||||
|
||||
Logger::Logger() : logToFileEnabled(false)
|
||||
{
|
||||
logBuffer.append(getClientVersion());
|
||||
logBuffer.append(getSystemArchitecture());
|
||||
std::cerr << getClientVersion().toStdString() << std::endl;
|
||||
std::cerr << getSystemArchitecture().toStdString() << std::endl;
|
||||
}
|
||||
|
||||
Logger::~Logger()
|
||||
|
@ -47,6 +53,7 @@ void Logger::openLogfileSession()
|
|||
fileStream.setDevice(&fileHandle);
|
||||
fileStream << "Log session started at " << QDateTime::currentDateTime().toString() << endl;
|
||||
fileStream << getClientVersion() << endl;
|
||||
fileStream << getSystemArchitecture() << endl;
|
||||
logToFileEnabled = true;
|
||||
}
|
||||
|
||||
|
@ -81,3 +88,27 @@ void Logger::internalLog(const QString message)
|
|||
if (logToFileEnabled)
|
||||
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 <QMutex>
|
||||
|
||||
class Logger : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static Logger& getInstance()
|
||||
{
|
||||
static Logger instance;
|
||||
return instance;
|
||||
}
|
||||
private:
|
||||
Logger();
|
||||
~Logger();
|
||||
// Singleton - Don't implement copy constructor and assign operator
|
||||
Logger(Logger const&);
|
||||
void operator=(Logger const&);
|
||||
#if defined(Q_PROCESSOR_X86_32)
|
||||
#define BUILD_ARCHITECTURE "32-bit"
|
||||
#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
|
||||
|
||||
bool logToFileEnabled;
|
||||
QTextStream fileStream;
|
||||
QFile fileHandle;
|
||||
QList<QString> logBuffer;
|
||||
QMutex mutex;
|
||||
public:
|
||||
void logToFile(bool enabled);
|
||||
void log(QtMsgType type, const QMessageLogContext &ctx, const QString message);
|
||||
QString getClientVersion();
|
||||
QList<QString> getLogBuffer() { return logBuffer; }
|
||||
protected:
|
||||
void openLogfileSession();
|
||||
void closeLogfileSession();
|
||||
protected slots:
|
||||
void internalLog(const QString message);
|
||||
signals:
|
||||
void logEntryAdded(QString message);
|
||||
class Logger : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static Logger& getInstance()
|
||||
{
|
||||
static Logger instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
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();
|
||||
// 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
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "localserver.h"
|
||||
#include "localserverinterface.h"
|
||||
#include "localclient.h"
|
||||
#include "logger.h"
|
||||
#include "settingscache.h"
|
||||
#include "tab_game.h"
|
||||
#include "version_string.h"
|
||||
|
@ -282,7 +283,7 @@ void MainWindow::actExit()
|
|||
void MainWindow::actAbout()
|
||||
{
|
||||
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)
|
||||
+ "<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>"
|
||||
|
|
Loading…
Reference in a new issue