-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
32 lines (24 loc) · 881 Bytes
/
main.cpp
File metadata and controls
32 lines (24 loc) · 881 Bytes
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
// main.cpp
#include "Logger.h"
#include <thread>
#include <chrono>
int main() {
Logger& logger = Logger::getInstance();
logger.init("my_app_logs.txt", LogLevel::INFO); // ← allows all levels
logger.log("Main thread: Application started", LogLevel::INFO);
logger.log("Disk space low", LogLevel::WARNING);
logger.log("Fatal error occurred", LogLevel::ERROR);
std::thread t1([&logger] {
logger.log("Thread 1: Startup", LogLevel::INFO);
logger.log("Thread 1: Something went wrong", LogLevel::ERROR);
});
std::thread t2([&logger] {
logger.log("Thread 2: Caution message", LogLevel::WARNING);
logger.log("Thread 2: Done", LogLevel::INFO);
});
t1.join();
t2.join();
logger.log("Main thread: Done", LogLevel::INFO);
logger.shutdown(); // ✅ call this before main exits
return 0;
}