-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogger.hpp
92 lines (72 loc) · 2.39 KB
/
Logger.hpp
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
#ifndef __LOG_H__
#define __LOG_H__
using namespace std;
class Logger {
/**
* @brief Logs para vizualizaçao personalizada, cada um é usado em um momento das camadas;
*/
public:
static void logBeginOfLayer(const string& layer) {
cout << Logger::green(("[" + layer + "]" +
string(60 - (layer.size()), '-') + "[START]"))
<< endl;
}
static void logEndOfLayer(const string& layer) {
cout << Logger::green(("[" + layer + "]" +
string(60 - (layer.size()), '-') + "[ END ]"))
<< endl;
}
static void logInfo(const string& message,
const string& typeMessage = "INFO",
const bool endLine = true) {
cout << Logger::blue("[" + typeMessage + "]: ") + message;
if (endLine) {
cout << endl;
}
}
/**
* @brief Adicionando cor ao print no terminal para melhorar o debug
*/
static string red(const string& str) {
return string{"\033[1m\033[31m" + str + "\033[0m"};
}
static string green(const string& str) {
return string{"\033[1m\033[32m" + str + "\033[0m"};
}
static string blue(const string& str) {
return string{"\033[1m\033[34m" + str + "\033[0m"};
}
/**
* @brief Printa o array de booleans no terminal
*/
static string bitsAsString(const vector<bool>& bits) {
string stringBits = "";
for (int i = 0; i < bits.size(); i++) {
if(bits[i]){
stringBits += '1';
}else{
stringBits += '0';
}
if ((i + 1) % 8 == 0) stringBits += " ";
}
return stringBits;
}
/**
* @brief Print para comparar dois arrays
*/
static void printDifference(const vector<bool>& og,
const vector<bool>& comp) {
cout << Logger::green(string(28, '-') + "[Diferenças]" +
string(28, '-'))
<< endl;
for (int i = 0, j = 0; i < og.size(); i++, j++) {
cout << ((og[i] != comp[i])
? Logger::red(to_string(comp[i]))
: to_string(comp[i]));
if ((j + 1) % 8 == 0) cout << " ";
}
cout << endl;
cout << endl;
}
};
#endif