-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.h
51 lines (42 loc) · 1.18 KB
/
utils.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
#pragma once
#include <iostream>
#include <string>
#include <filesystem>
#include <iostream>
class Logger {
Logger() {} // Private Constructor
Logger(Logger const&) = delete;
void operator=(Logger const&) = delete;
public:
enum class LogLevel {
DEBUG,
INFO,
WARNING,
ERROR
};
bool debug_mode;
static Logger& get_instance() {
static Logger instance;
return instance;
}
void set_debug_mode(bool mode) { debug_mode = mode; }
void log(const std::string& message, LogLevel level = LogLevel::INFO) {
const std::string resetColor = "\033[0m";
std::string colorCode;
switch (level) {
case LogLevel::DEBUG:
colorCode = "\033[34m"; // Blue
break;
case LogLevel::INFO:
colorCode = "\033[32m"; // Green
break;
case LogLevel::WARNING:
colorCode = "\033[33m"; // Yellow
break;
case LogLevel::ERROR:
colorCode = "\033[31m"; // Red
break;
}
std::cout << colorCode << message << resetColor << std::endl;
}
};