mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-03 20:13:56 -07:00
Log UI
This commit is contained in:
parent
e81a6d497b
commit
8db10be892
9 changed files with 178 additions and 12 deletions
40
cockatrice/src/logger.h
Normal file
40
cockatrice/src/logger.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#ifndef LOGGER_H
|
||||
#define LOGGER_H
|
||||
|
||||
#include <QTextStream>
|
||||
#include <QFile>
|
||||
#include <QVector>
|
||||
#include <QString>
|
||||
|
||||
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&);
|
||||
|
||||
bool logToFileEnabled;
|
||||
QTextStream fileStream;
|
||||
QFile fileHandle;
|
||||
|
||||
QVector<QString> logBuffer;
|
||||
public:
|
||||
void logToFile(bool enabled);
|
||||
void log(QtMsgType type, const QMessageLogContext &ctx, const QString &message);
|
||||
QVector<QString> getLogBuffer() { return logBuffer; }
|
||||
protected:
|
||||
void openLogfileSession();
|
||||
void closeLogfileSession();
|
||||
signals:
|
||||
void logEntryAdded(QString message);
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue