## Related Ticket(s) - Fixes #3558 
This commit is contained in:
parent
46b34d6515
commit
6e3fd30fcb
2 changed files with 20 additions and 6 deletions
|
@ -1,5 +1,7 @@
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "version_string.h"
|
#include "version_string.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
|
@ -13,9 +15,12 @@ Logger::Logger() : logToFileEnabled(false)
|
||||||
logBuffer.append(getClientVersion());
|
logBuffer.append(getClientVersion());
|
||||||
logBuffer.append(getSystemArchitecture());
|
logBuffer.append(getSystemArchitecture());
|
||||||
logBuffer.append(getSystemLocale());
|
logBuffer.append(getSystemLocale());
|
||||||
|
logBuffer.append(getClientInstallInfo());
|
||||||
logBuffer.append(QString("-").repeated(75));
|
logBuffer.append(QString("-").repeated(75));
|
||||||
std::cerr << getClientVersion().toStdString() << std::endl;
|
std::cerr << getClientVersion().toStdString() << std::endl;
|
||||||
std::cerr << getSystemArchitecture().toStdString() << std::endl;
|
std::cerr << getSystemArchitecture().toStdString() << std::endl;
|
||||||
|
std::cerr << getSystemLocale().toStdString() << std::endl;
|
||||||
|
std::cerr << getClientInstallInfo().toStdString() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::~Logger()
|
Logger::~Logger()
|
||||||
|
@ -50,6 +55,7 @@ void Logger::openLogfileSession()
|
||||||
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;
|
fileStream << getSystemArchitecture() << endl;
|
||||||
|
fileStream << getClientInstallInfo() << endl;
|
||||||
logToFileEnabled = true;
|
logToFileEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +74,7 @@ void Logger::log(QtMsgType /* type */, const QMessageLogContext & /* ctx */, con
|
||||||
QMetaObject::invokeMethod(this, "internalLog", Qt::QueuedConnection, Q_ARG(const QString &, message));
|
QMetaObject::invokeMethod(this, "internalLog", Qt::QueuedConnection, Q_ARG(const QString &, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::internalLog(const QString message)
|
void Logger::internalLog(QString message)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mutex);
|
QMutexLocker locker(&mutex);
|
||||||
|
|
||||||
|
@ -106,7 +112,14 @@ QString Logger::getClientOperatingSystem()
|
||||||
|
|
||||||
QString Logger::getSystemLocale()
|
QString Logger::getSystemLocale()
|
||||||
{
|
{
|
||||||
QString result;
|
QString result(QString("System Locale: ") + QLocale().name());
|
||||||
result.append(QString("System Locale: ") + QLocale().name());
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Logger::getClientInstallInfo()
|
||||||
|
{
|
||||||
|
// don't rely on settingsCache->getIsPortableBuild() since the logger is initialized earlier
|
||||||
|
bool isPortable = QFile::exists(qApp->applicationDirPath() + "/portable.dat");
|
||||||
|
QString result(QString("Install Mode: ") + (isPortable ? "Portable" : "Standard"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void logToFile(bool enabled);
|
void logToFile(bool enabled);
|
||||||
void log(QtMsgType type, const QMessageLogContext &ctx, const QString message);
|
void log(QtMsgType type, const QMessageLogContext &ctx, QString message);
|
||||||
QString getClientVersion();
|
QString getClientVersion();
|
||||||
QString getClientOperatingSystem();
|
QString getClientOperatingSystem();
|
||||||
QString getSystemArchitecture();
|
QString getSystemArchitecture();
|
||||||
QString getSystemLocale();
|
QString getSystemLocale();
|
||||||
|
QString getClientInstallInfo();
|
||||||
QList<QString> getLogBuffer()
|
QList<QString> getLogBuffer()
|
||||||
{
|
{
|
||||||
return logBuffer;
|
return logBuffer;
|
||||||
|
@ -40,7 +41,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Logger();
|
Logger();
|
||||||
~Logger();
|
~Logger() override;
|
||||||
// Singleton - Don't implement copy constructor and assign operator
|
// Singleton - Don't implement copy constructor and assign operator
|
||||||
Logger(Logger const &);
|
Logger(Logger const &);
|
||||||
void operator=(Logger const &);
|
void operator=(Logger const &);
|
||||||
|
@ -56,7 +57,7 @@ protected:
|
||||||
void closeLogfileSession();
|
void closeLogfileSession();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void internalLog(const QString message);
|
void internalLog(QString message);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void logEntryAdded(QString message);
|
void logEntryAdded(QString message);
|
||||||
|
|
Loading…
Reference in a new issue