mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-15 11:38:49 -07:00
Core qt module for libs (#6278)
* Move logger and key signals from libcockatrice_utility to Cockatrice. Took 9 minutes * Only link Qt::Core instead of COCKATRICE_QT_MODULES to libraries, if possible. Took 2 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
adff828415
commit
f24c36d6b1
19 changed files with 23 additions and 28 deletions
72
cockatrice/src/interface/logger.h
Normal file
72
cockatrice/src/interface/logger.h
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/**
|
||||
* @file logger.h
|
||||
* @ingroup Core
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
|
||||
#ifndef LOGGER_H
|
||||
#define LOGGER_H
|
||||
|
||||
#include <QFile>
|
||||
#include <QMutex>
|
||||
#include <QString>
|
||||
#include <QTextStream>
|
||||
#include <QVector>
|
||||
|
||||
#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
|
||||
|
||||
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();
|
||||
QString getSystemLocale();
|
||||
QString getClientInstallInfo();
|
||||
QList<QString> getLogBuffer()
|
||||
{
|
||||
return logBuffer;
|
||||
}
|
||||
|
||||
private:
|
||||
Logger();
|
||||
~Logger() override;
|
||||
// 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(const QString &message);
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue