Files
amnezia-client/client/logger.h
T

52 lines
1.1 KiB
C++
Raw Normal View History

2022-12-28 13:41:45 +03:00
#ifndef LOGGER_H
#define LOGGER_H
2020-11-23 16:20:25 +03:00
2020-12-26 15:03:51 +03:00
#include <QDebug>
#include <QDir>
2020-11-23 16:20:25 +03:00
#include <QFile>
#include <QString>
2020-12-26 15:03:51 +03:00
#include <QTextStream>
2020-11-23 16:20:25 +03:00
2022-02-04 17:49:48 +03:00
#include "ui/property_helper.h"
2022-12-28 13:41:45 +03:00
class Logger : public QObject
2020-11-23 16:20:25 +03:00
{
2022-02-04 17:49:48 +03:00
Q_OBJECT
AUTO_PROPERTY(QString, sshLog)
AUTO_PROPERTY(QString, allLog)
2020-11-23 16:20:25 +03:00
public:
2022-12-28 13:41:45 +03:00
static Logger& Instance();
2022-02-04 17:49:48 +03:00
static void appendSshLog(const QString &log);
static void appendAllLog(const QString &log);
2020-11-23 16:20:25 +03:00
static bool init();
static void deInit();
2020-12-16 06:02:22 +03:00
static bool openLogsFolder();
2021-10-07 22:21:04 +03:00
static bool openServiceLogsFolder();
2020-12-26 15:03:51 +03:00
static QString appLogFileNamePath();
2022-01-30 17:35:57 +03:00
static void clearLogs();
static void clearServiceLogs();
static void cleanUp();
2020-11-23 16:20:25 +03:00
2022-02-01 19:48:59 +03:00
static QString userLogsFilePath();
2022-02-04 17:49:48 +03:00
static QString getLogFile();
2022-02-01 19:48:59 +03:00
2020-11-23 16:20:25 +03:00
private:
2022-12-28 13:41:45 +03:00
Logger() {}
Logger(Logger const &) = delete;
Logger& operator= (Logger const&) = delete;
2022-02-04 17:49:48 +03:00
2020-12-26 23:17:20 +03:00
static QString userLogsDir();
2020-12-16 06:02:22 +03:00
static QFile m_file;
static QTextStream m_textStream;
static QString m_logFileName;
2020-11-23 16:20:25 +03:00
2020-12-16 06:02:22 +03:00
friend void debugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg);
2020-11-23 16:20:25 +03:00
};
2022-12-28 13:41:45 +03:00
#endif // LOGGER_H