-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.hpp
More file actions
53 lines (43 loc) · 1.48 KB
/
Copy pathlog.hpp
File metadata and controls
53 lines (43 loc) · 1.48 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
#pragma once
#include "wids/svgBtn.hpp"
#include <QString>
bool doubleCheck(QString prompt);
namespace Log {
enum Level { DEBUG, INFO, WARN, ERROR };
struct LogType {
inline LogType(Level l, QString m, QString module) : lvl(l), msg(m), mod(module) {};
Level lvl;
QString msg;
QString mod;
};
extern std::vector<LogType> logs;
class Log {
public:
Log(QString module, Level level = INFO) : mod(module), lvl(level), buf(), stream(&buf) {}
~Log();
template <typename T>
inline Log& operator<<(const T& value) {
stream << value;
return *this;
}
private:
QString buf;
QTextStream stream;
Level lvl;
QString mod;
};
inline Log Debug(QString module) { return Log(module, DEBUG); }
inline Log Info(QString module) { return Log(module, INFO); }
inline Log Warn(QString module) { return Log(module, WARN); }
inline Log Error(QString module) { return Log(module, ERROR); }
}
/** DeBug Log - for debugging purposes ONLY - do not use in production - instead use Log::Debug(module) */
inline Log::Log DBL() { return Log::Debug("DEBUG"); }
/** DeBug Log with Print - for debugging purposes ONLY - do not use in production - instead use Log::Info(module) */
inline Log::Log DBLP() { return Log::Info("DEBUG"); }
void showLogWindow();
class LogAlert : public SvgBtn {
public:
LogAlert(Log::Level lvl, QString msg);
void deleteMe();
};