forked from cnr-isti-vclab/meshlab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGLLogStream.h
More file actions
120 lines (103 loc) · 4.06 KB
/
GLLogStream.h
File metadata and controls
120 lines (103 loc) · 4.06 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/****************************************************************************
* VCGLib o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004
\/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
* All rights reserved. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. *
* *
****************************************************************************/
#ifndef GLLOGSTREAM_H
#define GLLOGSTREAM_H
#include <list>
#include <utility>
#include <QMultiMap>
#include <QPair>
#include <QString>
#include <QObject>
#ifdef _WIN32
#ifdef ML_EXPORT_SYMBOLS
#define ML_DLL_EXPORT Q_DECL_EXPORT
#else
#define ML_DLL_EXPORT Q_DECL_IMPORT
#endif
#else //_WIN32
#define ML_DLL_EXPORT
#endif
/**
This is the logging class.
One for each document. Responsible of getting an history of the logging message printed out by filters.
*/
class ML_DLL_EXPORT
GLLogStream : public QObject
{
Q_OBJECT
public:
enum Levels
{
SYSTEM = 0,
WARNING = 1,
FILTER = 2,
DEBUG = 3
};
static constexpr std::size_t buf_size = 4096;
GLLogStream();
~GLLogStream() {}
void print(QStringList &list) const; // Fills a QStringList with the log entries
void save(int Level, const char *filename);
void clear();
template <typename... Ts>
void logf(int Level, const char * f, Ts&&... ts )
{
char buf[buf_size];
int chars_written = snprintf(buf, buf_size, f, std::forward<Ts>(ts)...);
log(Level, buf);
if(chars_written >= static_cast<int>(buf_size)){
log(Level, "Log message truncated.");
}
}
void log(int level, const char * buf);
void log(int level, const std::string& logMessage);
void log(int level, const QString& logMessage);
void setBookmark();
void clearBookmark();
void backToBookmark();
const QList<std::pair<int, QString> >& logStringList() const;
const QMultiMap<QString, QPair<QString, QString> >& realTimeLogMultiMap() const;
void clearRealTimeLog();
template <typename... Ts>
void realTimeLogf(const QString& Id, const QString &meshName, const char * f, Ts&&... ts )
{
char buf[buf_size];
int chars_written = snprintf(buf, buf_size, f, std::forward<Ts>(ts)...);
realTimeLog(Id, meshName, buf);
if(chars_written >= static_cast<int>(buf_size)){
realTimeLog(Id, meshName, "Log message truncated.");
}
}
void realTimeLog(const QString& Id, const QString &meshName, const QString& text);
signals:
void logUpdated();
private:
int bookmark; /// this field is used to place a bookmark for restoring the log. Useful for previeweing
QList<std::pair<int, QString> > logTextList;
// The list of strings used in realtime display of info over the mesh.
// Each box is identified by the title, name of the mesh and text.
// the name of the mesh is shown only if two or more box with the same title are shown.
QMultiMap<QString, QPair<QString, QString> > realTimeLogText;
};
#endif //GLLOGSTREAM_H