aboutsummaryrefslogtreecommitdiff
path: root/src/base/log/StdioLogTarget.cpp
blob: 348134265d95bad65af00f65373334872c0b51f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "cru/base/log/StdioLogTarget.h"

#include <iostream>
#include "cru/base/StringUtil.h"

namespace cru::log {
StdioLogTarget::StdioLogTarget() {}

StdioLogTarget::~StdioLogTarget() {}

void StdioLogTarget::Write(log::LogLevel level, std::string message) {
#ifdef CRU_PLATFORM_WINDOWS
  auto s = string::ToUtf16(message);
  if (level == log::LogLevel::Error) {
    std::wcerr << s << std::endl;
  } else {
    std::wcout << s << std::endl;
  }
#else
  if (level == log::LogLevel::Error) {
    std::cerr << message << std::endl;
  } else {
    std::cout << message << std::endl;
  }
#endif
}
}  // namespace cru::log