-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathlogger.h
More file actions
56 lines (42 loc) · 1.21 KB
/
logger.h
File metadata and controls
56 lines (42 loc) · 1.21 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
#pragma once
#include <intercept.hpp>
#include <mutex>
#include <filesystem>
#include <fstream>
#include "../intercept/src/host/common/singleton.hpp"
namespace intercept {
namespace types {
class r_string;
}
}
class Logger : public intercept::singleton<Logger> {
public:
void init(std::filesystem::path outputDirectory);
void setQueryLogEnabled(bool isEnabled) {
queryLogEnabled = isEnabled;
refreshLogfiles();
}
void logQuery(intercept::types::r_string message);
bool isQueryLogEnabled() const {
return queryLogEnabled;
}
void setThreadLogEnabled(bool isEnabled) {
threadLogEnabled = isEnabled;
refreshLogfiles();
}
void logThread(intercept::types::r_string message);
bool isThreadLogEnabled() const {
return threadLogEnabled;
}
private:
void pushTimestamp(std::ostream& str) const;
void refreshLogfiles();
void deleteOldLogs(int days);
std::mutex queryLog_lock;
bool queryLogEnabled = false;
std::unique_ptr<std::ofstream> queryLog;
std::mutex threadLog_lock;
bool threadLogEnabled = false;
std::unique_ptr<std::ofstream> threadLog;
std::filesystem::path outputDirectory;
};