diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-05-14 12:53:59 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-05-14 12:53:59 -0400 |
commit | bee4194f9e12c9d2210a5ecba7249bdfe3f3deda (patch) | |
tree | 1212b2f05cea09e4fbf8f1a3c57418fb3e92fc36 /src/logger.cpp | |
parent | dff1d7382f2af91e50561bfdb9eb83773ac7c010 (diff) | |
download | lingo-ap-tracker-bee4194f9e12c9d2210a5ecba7249bdfe3f3deda.tar.gz lingo-ap-tracker-bee4194f9e12c9d2210a5ecba7249bdfe3f3deda.tar.bz2 lingo-ap-tracker-bee4194f9e12c9d2210a5ecba7249bdfe3f3deda.zip |
Switch to wx logging
Diffstat (limited to 'src/logger.cpp')
-rw-r--r-- | src/logger.cpp | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/src/logger.cpp b/src/logger.cpp index 4b722c8..dddcc4a 100644 --- a/src/logger.cpp +++ b/src/logger.cpp | |||
@@ -1,32 +1,27 @@ | |||
1 | #include "logger.h" | 1 | #include "logger.h" |
2 | 2 | ||
3 | #include <chrono> | ||
4 | #include <fstream> | ||
5 | #include <mutex> | ||
6 | |||
7 | #include "global.h" | 3 | #include "global.h" |
8 | 4 | ||
9 | namespace { | 5 | Logger::Logger() : logfile_(GetAbsolutePath("debug.log")) {} |
10 | 6 | ||
11 | class Logger { | 7 | void Logger::Flush() { |
12 | public: | 8 | wxLog::Flush(); |
13 | Logger() : logfile_(GetAbsolutePath("debug.log")) {} | ||
14 | 9 | ||
15 | void LogLine(const std::string& text) { | 10 | std::lock_guard guard(file_mutex_); |
16 | std::lock_guard guard(file_mutex_); | 11 | logfile_.flush(); |
17 | logfile_ << "[" << std::chrono::system_clock::now() << "] " << text | 12 | } |
18 | << std::endl; | ||
19 | logfile_.flush(); | ||
20 | } | ||
21 | 13 | ||
22 | private: | 14 | Logger::~Logger() { |
23 | std::ofstream logfile_; | 15 | std::lock_guard guard(file_mutex_); |
24 | std::mutex file_mutex_; | 16 | logfile_.flush(); |
25 | }; | 17 | } |
26 | 18 | ||
27 | } // namespace | 19 | void Logger::DoLogText(const wxString& msg) { |
20 | #ifdef _WIN64 | ||
21 | OutputDebugStringA(msg.c_str()); | ||
22 | OutputDebugStringA("\r\n"); | ||
23 | #endif | ||
28 | 24 | ||
29 | void TrackerLog(const std::string& text) { | 25 | std::lock_guard guard(file_mutex_); |
30 | static Logger* instance = new Logger(); | 26 | logfile_ << msg << std::endl; |
31 | instance->LogLine(text); | ||
32 | } | 27 | } |