This repository was archived by the owner on Mar 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplogger.h
66 lines (55 loc) · 1.43 KB
/
applogger.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
// SmartServer
// Copyright (C) 2021 АО "Нефтеавтоматика"
//
// Разработчик
// Ананьев А.А. <[email protected]>
//
#ifndef APPLOGGER_H
#define APPLOGGER_H
#include <mutex>
#include <QFile>
#include <QtDebug>
#include <QListWidget>
#include <QApplication>
class AppLogger
{
public:
static AppLogger& getInstance()
{
static AppLogger instance;
return instance;
}
///
/// \brief setup
/// \param app
/// \param filename
///
void setup(const QApplication& app, const QString _filename = "");
///
/// \brief setup
/// \param app
/// \param listWidget
///
void setup(const QApplication& app, QListWidget* listWidget, int maxRows = 500);
///
/// \brief hello
/// \param app
///
void hello(const QApplication& app) const;
private:
AppLogger();
~AppLogger();
AppLogger(AppLogger const&) = delete;
void operator=(AppLogger const&) = delete;
private:
QFile _logFile;
QString _filename;
int _maxRows;
QListWidget* _listWidget;
static std::mutex mutex;
static void defaultHandler(QtMsgType type, const QMessageLogContext& ctx, const QString& msg);
static void fileHandler(QtMsgType type, const QMessageLogContext& ctx, const QString& msg);
static void listWidgetHandler(QtMsgType type, const QMessageLogContext& ctx, const QString& msg);
};
#endif // APPLOGGER_H