OSCAR-code/oscar/logger.h
Guy Scharf b338d7aa3d Check for ability to write to data directory at startup
Show critical error message and exit OSCAR if unable to write to data directory
    Improve qWarning message in logger.cpp
    Present warning dialog if logger cannot write to disk
2020-08-16 12:46:36 -07:00

55 lines
1.2 KiB
C++

#ifndef LOGGER_H
#define LOGGER_H
#include <QDebug>
#include <QRunnable>
#include <QThreadPool>
#include <QMutex>
#include <QWaitCondition>
#include <QTime>
void initializeLogger();
void shutdownLogger();
QString GetLogDir();
void rotateLogs(const QString & filePath, int maxPrevious=-1);
void MyOutputHandler(QtMsgType type, const QMessageLogContext &context, const QString &msgtxt);
class LogThread:public QObject, public QRunnable
{
Q_OBJECT
public:
explicit LogThread() : QRunnable() { running = false; logtime.start(); connected = false; m_logFile = nullptr; m_logStream = nullptr; }
virtual ~LogThread();
void run();
void append(QString msg);
void appendClean(QString msg);
bool isRunning() { return running; }
void connectionReady();
bool logToFile();
QString logFileName();
void quit();
QStringList buffer;
QMutex strlock;
QThreadPool *threadpool;
signals:
void outputLog(QString);
protected:
volatile bool running;
QTime logtime;
bool connected;
class QFile* m_logFile;
class QTextStream* m_logStream;
QWaitCondition logTrigger;
};
extern LogThread * logger;
extern QThreadPool * otherThreadPool;
#endif // LOGGER_H