diff options
author | crupest <crupest@outlook.com> | 2020-10-18 21:09:21 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-10-18 21:09:21 +0800 |
commit | 5729a5aa1b443e3e25f3e14dee29636d3b31a6f8 (patch) | |
tree | 264efb8b0abdbbe1bcff813d9f10288f78cab905 /src/win | |
parent | 58af3c346e7dd72be077bf5231bb7bf193591288 (diff) | |
download | cru-5729a5aa1b443e3e25f3e14dee29636d3b31a6f8.tar.gz cru-5729a5aa1b443e3e25f3e14dee29636d3b31a6f8.tar.bz2 cru-5729a5aa1b443e3e25f3e14dee29636d3b31a6f8.zip |
...
Diffstat (limited to 'src/win')
-rw-r--r-- | src/win/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/win/StdOutLogger.hpp | 24 | ||||
-rw-r--r-- | src/win/native/UiApplication.cpp | 3 |
3 files changed, 28 insertions, 0 deletions
diff --git a/src/win/CMakeLists.txt b/src/win/CMakeLists.txt index 75b0a7ca..06f947a1 100644 --- a/src/win/CMakeLists.txt +++ b/src/win/CMakeLists.txt @@ -2,6 +2,7 @@ set(CRU_WIN_BASE_INCLUDE_DIR ${CRU_INCLUDE_DIR}/cru/win/) add_library(cru_win_base STATIC DebugLogger.hpp + StdOutLogger.hpp Exception.cpp HeapDebug.cpp diff --git a/src/win/StdOutLogger.hpp b/src/win/StdOutLogger.hpp new file mode 100644 index 00000000..bff8b30e --- /dev/null +++ b/src/win/StdOutLogger.hpp @@ -0,0 +1,24 @@ +#include "cru/common/Base.hpp" +#include "cru/win/WinPreConfig.hpp" + +#include "cru/common/Logger.hpp" + +#include <cwchar> + +namespace cru::platform::win { +class WinStdOutLoggerSource : public ::cru::log::ILogSource { + public: + WinStdOutLoggerSource() = default; + + CRU_DELETE_COPY(WinStdOutLoggerSource) + CRU_DELETE_MOVE(WinStdOutLoggerSource) + + ~WinStdOutLoggerSource() = default; + + void Write(::cru::log::LogLevel level, const std::u16string& s) override { + CRU_UNUSED(level) + + std::fputws(reinterpret_cast<const wchar_t*>(s.c_str()), stdout); + } +}; +} // namespace cru::platform::win diff --git a/src/win/native/UiApplication.cpp b/src/win/native/UiApplication.cpp index a806db88..198f03f2 100644 --- a/src/win/native/UiApplication.cpp +++ b/src/win/native/UiApplication.cpp @@ -1,6 +1,7 @@ #include "cru/win/native/UiApplication.hpp" #include "../DebugLogger.hpp" +#include "../StdOutLogger.hpp" #include "TimerManager.hpp" #include "WindowManager.hpp" #include "cru/common/Logger.hpp" @@ -30,6 +31,8 @@ WinUiApplication::WinUiApplication() { log::Logger::GetInstance()->AddSource( std::make_unique<::cru::platform::win::WinDebugLoggerSource>()); + log::Logger::GetInstance()->AddSource( + std::make_unique<::cru::platform::win::WinStdOutLoggerSource>()); graph_factory_ = std::make_unique<cru::platform::graph::win::direct::DirectGraphFactory>(); |