From 33bf1f9653ed608de5554940dc8a0c3f5dc7e4ea Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 10 Jun 2024 19:13:22 -0400 Subject: Go back to old logging system Brought in libfmt to handle string formatting and replace a bunch of ostringstream uses. --- src/logger.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/logger.cpp (limited to 'src/logger.cpp') 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 @@ +#include "logger.h" + +#include +#include +#include + +#include "global.h" + +namespace { + +class Logger { + public: + Logger() : logfile_(GetAbsolutePath("debug.log")) {} + + void LogLine(const std::string& text) { + std::lock_guard guard(file_mutex_); + logfile_ << "[" << std::chrono::system_clock::now() << "] " << text + << std::endl; + logfile_.flush(); + } + + private: + std::ofstream logfile_; + std::mutex file_mutex_; +}; + +} // namespace + +void TrackerLog(std::string text) { + static Logger* instance = new Logger(); + instance->LogLine(text); +} -- cgit 1.4.1