about summary refs log tree commit diff stats
path: root/src/logger.cpp
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-07-16 15:17:21 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2024-07-16 15:17:21 -0400
commit558fcd9bf0852b5c909822c374f7e445b63026e5 (patch)
treef78d74f389c63f83da1878c9982de9a8e3343df0 /src/logger.cpp
parent2944687cbbaa53d0815fea9f5f2506500e2e1db3 (diff)
parenta40d5a90a4759ecb03fe4591878c011d3c8c07be (diff)
downloadlingo-ap-tracker-558fcd9bf0852b5c909822c374f7e445b63026e5.tar.gz
lingo-ap-tracker-558fcd9bf0852b5c909822c374f7e445b63026e5.tar.bz2
lingo-ap-tracker-558fcd9bf0852b5c909822c374f7e445b63026e5.zip
Merge branch 'main' into panels
Diffstat (limited to 'src/logger.cpp')
-rw-r--r--src/logger.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/logger.cpp b/src/logger.cpp new file mode 100644 index 0000000..09fc331 --- /dev/null +++ b/src/logger.cpp
@@ -0,0 +1,32 @@
1#include "logger.h"
2
3#include <chrono>
4#include <fstream>
5#include <mutex>
6
7#include "global.h"
8
9namespace {
10
11class Logger {
12 public:
13 Logger() : logfile_(GetAbsolutePath("debug.log")) {}
14
15 void LogLine(const std::string& text) {
16 std::lock_guard guard(file_mutex_);
17 logfile_ << "[" << std::chrono::system_clock::now() << "] " << text
18 << std::endl;
19 logfile_.flush();
20 }
21
22 private:
23 std::ofstream logfile_;
24 std::mutex file_mutex_;
25};
26
27} // namespace
28
29void TrackerLog(std::string text) {
30 static Logger* instance = new Logger();
31 instance->LogLine(text);
32}