feat: v0.1.0更新
This commit is contained in:
41
include/core/Logger.h
Normal file
41
include/core/Logger.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef LOGGER_H
|
||||
#define LOGGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QMutex>
|
||||
|
||||
class Logger : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static Logger* instance();
|
||||
|
||||
void setLogFile(const QString &filePath);
|
||||
void setMaxLines(int maxLines);
|
||||
|
||||
void log(const QString &message);
|
||||
void debug(const QString &message);
|
||||
void info(const QString &message);
|
||||
void warning(const QString &message);
|
||||
void error(const QString &message);
|
||||
|
||||
private:
|
||||
explicit Logger(QObject *parent = nullptr);
|
||||
~Logger();
|
||||
|
||||
void writeLog(const QString &level, const QString &message);
|
||||
void checkAndTrimLog();
|
||||
|
||||
static Logger *s_instance;
|
||||
|
||||
QString m_logFilePath;
|
||||
int m_maxLines;
|
||||
QMutex m_mutex;
|
||||
int m_currentLines;
|
||||
};
|
||||
|
||||
#endif // LOGGER_H
|
||||
Reference in New Issue
Block a user