-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.h
More file actions
37 lines (28 loc) · 803 Bytes
/
logger.h
File metadata and controls
37 lines (28 loc) · 803 Bytes
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
#ifndef LOGGER_H
#define LOGGER_H
#include <iostream>
#include <pin.H>
enum LevelDebug { _ERROR = 0, _WARNING, _INFO, _DEBUG, _ALL_LOG };
class Log {
static LevelDebug gLevel;
LevelDebug cLevel;
public:
Log(const LevelDebug level, const std::string &fileName,
const std::string &funcName, const int line) {
cLevel = level;
if (cLevel <= gLevel)
std::cout << fileName << "/" << funcName << ":" << line << ": ";
}
template <class T> Log &operator<<(const T &v) {
if (cLevel <= gLevel)
std::cout << v;
return *this;
}
~Log() {
if (cLevel <= gLevel)
std::cout << std::endl;
}
static void setGLevel(const LevelDebug level) { gLevel = level; }
};
#define MAGIC_LOG(LEVEL) Log((LEVEL), __FILE__, __FUNCTION__, __LINE__)
#endif // LOGGER_H