-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFELog.h
91 lines (70 loc) · 1.92 KB
/
FELog.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
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
#pragma once
#include "FETime.h"
namespace FocalEngine
{
enum LOG_SEVERITY
{
FE_LOG_INFO = 0,
FE_LOG_DEBUG = 1,
FE_LOG_WARNING = 2,
FE_LOG_ERROR = 3,
FE_LOG_FATAL_ERROR = 4
};
struct LogItem
{
std::string Text;
LOG_SEVERITY Severity;
int Count;
std::string Topic;
uint64_t TimeStamp;
DWORD ThreadID;
LogItem();
~LogItem();
bool operator==(const LogItem& Other) const
{
return (Text == Other.Text && Severity == Other.Severity);
}
};
}
namespace std
{
template <> struct std::hash<FocalEngine::LogItem>
{
size_t operator()(const FocalEngine::LogItem& Object) const
{
return ((std::hash<std::string>()(Object.Text) ^ (Object.Severity << 1)) >> 1);
}
};
}
namespace FocalEngine
{
class FELOG
{
public:
SINGLETON_PUBLIC_PART(FELOG)
void Add(std::string Text, std::string Topic = "FE_LOG_GENERAL", LOG_SEVERITY Severity = FE_LOG_INFO);
std::vector<LogItem> GetLogItems(std::string Topic);
const int SeverityLevelsCount = 5;
std::string SeverityLevelToString(LOG_SEVERITY Severity);
bool IsTopicFileOutputActive(std::string Topic);
void DisableTopicFileOutput(std::string TopicToDisable);
void EnableTopicFileOutput(std::string TopicToEnable);
bool IsFileOutputActive();
void SetFileOutput(bool NewValue);
std::vector<std::string> GetTopicList();
bool IsAppendingMsgWithTimeStamp();
void SetShouldAppendMsgWithTimeStamp(bool NewValue);
bool IsAppendingMsgWithThreadID();
void SetShouldAppendMsgWithThreadID(bool NewValue);
private:
SINGLETON_PRIVATE_PART(FELOG)
std::unordered_map<std::string, std::unordered_map<LogItem, LogItem>> Topics;
std::unordered_map<std::string, bool> DisabledTopics;
bool bFileOutput = false;
std::unordered_map<std::string, std::fstream*> TopicFiles;
void OutputToFile(const LogItem* Item);
bool bShouldAppendMsgWithTimeStamp = false;
bool bShouldAppendMsgWithThreadID = false;
};
#define LOG FELOG::getInstance()
}