-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathlogger.h
More file actions
107 lines (81 loc) · 2.7 KB
/
logger.h
File metadata and controls
107 lines (81 loc) · 2.7 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
#pragma once
#include <map>
#include <ostream>
#include <string>
#include <utility>
#include <vector>
namespace dotenv
{
class logger
{
private:
enum severity
{
FATAL = 0,
ERROR = 1,
WARN = 2,
INFO = 3,
DEBUG = 4,
TRACE = 5
};
class position
{
public:
struct less
{
bool operator()(const position& p1, const position& p2) const;
};
public:
position(const size_t line, const size_t pos);
position(const position& position) = default;
virtual ~position() = default;
bool operator<(const position& p) const;
private:
size_t line;
size_t pos;
};
public:
logger(bool greedy = false);
logger(const logger& logger);
~logger() = default;
void fatal(const std::string& msg,
const size_t line = 0,
const size_t pos = 0);
void error(const std::string& msg,
const size_t line = 0,
const size_t pos = 0);
void warn(const std::string& msg,
const size_t line = 0,
const size_t pos = 0);
void info(const std::string& msg,
const size_t line = 0,
const size_t pos = 0);
void debug(const std::string& msg,
const size_t line = 0,
const size_t pos = 0);
void trace(const std::string& msg,
const size_t line = 0,
const size_t pos = 0);
void flush();
void clear();
private:
void place_log(severity severity,
const std::string& msg,
const size_t line,
const size_t pos);
void flush_severity(severity severity);
void clear_severity(severity severity);
private:
bool _greedy;
std::multimap<position, std::string, position::less> _fatal;
std::multimap<position, std::string, position::less> _error;
std::multimap<position, std::string, position::less> _warn;
std::multimap<position, std::string, position::less> _info;
std::multimap<position, std::string, position::less> _debug;
std::multimap<position, std::string, position::less> _trace;
const std::vector<std::multimap<position, std::string, position::less>*> _p_severity;
static const std::string _name;
static const std::vector<std::string> _severity_lvls;
static const std::vector<std::ostream*> _out_severity;
};
}