This commit is contained in:
Fabio Bas 2016-06-24 10:39:44 +02:00
parent e81a6d497b
commit 8db10be892
9 changed files with 178 additions and 12 deletions

40
cockatrice/src/logger.h Normal file
View 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