RabbitCommon v2.3.3
Loading...
Searching...
No Matches
Log.h
1
9#ifndef RABBIT_COMMON_LOG_H
10#define RABBIT_COMMON_LOG_H
11
12#pragma once
13#include <QObject>
14#include <QLoggingCategory>
15#include <QMutex>
16#include <QFile>
17#include <QTextStream>
18#include <QTimer>
19#include <QFileSystemWatcher>
20
21namespace RabbitCommon {
22
23#ifdef HAVE_RABBITCOMMON_GUI
24 void OpenLogConfigureFile();
25 void OpenLogFile();
26 void OpenLogFolder();
27#endif
28
33class CLog : QObject
34{
35 Q_OBJECT
36
37public:
38 static CLog* Instance();
39 virtual ~CLog();
40
41 QString GetLogConfigureFile();
42 QString GetLogFile();
43 QString GetLogDir();
44
45 int SetFilter(const QString &szInclude, const QString &szExclude);
46 int GetFilter(QString &szInclude, QString &szExclude);
47
48private:
49 CLog();
50
51 QString m_szConfigureFile;
52
53 QString m_szPath;
54 QString m_szName;
55 QString m_szDateFormat;
56 qint64 m_nLength; // Unit: byte
57 int m_nCount;
58 QTimer m_Timer;
59 QFileSystemWatcher m_Watcher;
60
61 #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
62 static void myMessageOutput(QtMsgType type,
63 const QMessageLogContext &context,
64 const QString &msg);
65 #else
66 static void myMessageOutput(QtMsgType, const char *);
67 #endif
68 void checkFileCount();
69 bool checkFileLength();
70 bool checkFileName();
71 QString getFileName();
72 QString getNextFileName(const QString szFile);
73 QString getBaseName();
74 int LoadConfigure(const QString &szFile);
75
76private Q_SLOTS:
77 void slotTimeout();
78 void slotFileChanged(const QString &szPath);
79};
80
81} // End namespace RabbitCommon
82
83#endif // RABBIT_COMMON_LOG_H