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