about summary refs log tree commit diff stats
path: root/src/logger.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/logger.cpp')
-rw-r--r--src/logger.cpp39
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
9namespace { 5Logger::Logger() : logfile_(GetAbsolutePath("debug.log")) {}
10 6
11class Logger { 7void 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: 14Logger::~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 19void Logger::DoLogText(const wxString& msg) {
20#ifdef _WIN64
21 OutputDebugStringA(msg.c_str());
22 OutputDebugStringA("\r\n");
23#endif
28 24
29void 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}