-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLog.h
37 lines (30 loc) · 884 Bytes
/
Log.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
// EmbedErr
// By: Sina Tashakkori, QVLx Labs
#ifndef LOG_H
#define LOG_H
#include <fstream>
class Logger {
public:
Logger() {
logFilePath = "log.txt";
}
template <typename... Args>
void log(Args&&... args) {
std::ofstream outputFile(logFilePath, std::ios::app);
if (outputFile.is_open()) {
((outputFile << std::forward<Args>(args)), ...);
outputFile << std::endl;
}
else { std::cerr << "Log could not open output file." << std::endl; }
}
void clear() {
std::ofstream outputFile(logFilePath, std::ios::out);
if (outputFile.is_open()) {
outputFile << ""; // Write an empty string to clear
}
else { std::cerr << "Log could not open file." << std::endl; }
}
private:
std::string logFilePath;
};
#endif