2025-04-16 21:08:47 +08:00
|
|
|
#ifndef LOGGER_H
|
|
|
|
|
#define LOGGER_H
|
|
|
|
|
|
|
|
|
|
#include <QLoggingCategory>
|
|
|
|
|
#include <QtCore/qobject.h>
|
|
|
|
|
#include <QtLogging>
|
|
|
|
|
#include <QtDebug>
|
|
|
|
|
|
|
|
|
|
Q_DECLARE_LOGGING_CATEGORY(Application)
|
|
|
|
|
Q_DECLARE_LOGGING_CATEGORY(Window)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Logging: public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
static void setupLogging();
|
|
|
|
|
|
|
|
|
|
private:
|
2025-04-17 09:37:58 +08:00
|
|
|
static void logMessageHandler(QtMsgType, const QMessageLogContext &, const QString &);
|
2025-04-16 21:08:47 +08:00
|
|
|
static void rollLogFiles();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
static qint64 maxFileSize;
|
|
|
|
|
static int maxBackupFiles;
|
2025-04-17 09:37:58 +08:00
|
|
|
static bool outputToConsole;
|
|
|
|
|
static bool outputToFile;
|
2025-04-16 21:08:47 +08:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
static QString fileName;
|
|
|
|
|
static QString messagePattern;
|
|
|
|
|
static QtMessageHandler originalHandler;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // LOGGER_H
|