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:
BruebachL 2025-11-05 18:51:08 +01:00 committed by GitHub
parent adff828415
commit f24c36d6b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 23 additions and 28 deletions

View 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