#include "logger.h"

#include "global.h"

Logger::Logger() : logfile_(GetAbsolutePath("debug.log")) {}

void Logger::Flush() {
  wxLog::Flush();

  std::lock_guard guard(file_mutex_);
  logfile_.flush();
}

Logger::~Logger() {
  std::lock_guard guard(file_mutex_);
  logfile_.flush();
}

void Logger::DoLogText(const wxString& msg) {
#ifdef _WIN64
  OutputDebugStringA(msg.c_str());
  OutputDebugStringA("\r\n");
#endif

  std::lock_guard guard(file_mutex_);
  logfile_ << msg << std::endl;
}