mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-30 02:19:35 +08:00
@@ -7,13 +7,20 @@
|
|||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
|
||||||
# include <spdlog/details/null_mutex.h>
|
# include <spdlog/details/null_mutex.h>
|
||||||
|
# if defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
|
||||||
|
# include <spdlog/details/os.h>
|
||||||
|
# endif
|
||||||
# include <spdlog/sinks/base_sink.h>
|
# include <spdlog/sinks/base_sink.h>
|
||||||
|
|
||||||
# include <mutex>
|
# include <mutex>
|
||||||
# include <string>
|
# include <string>
|
||||||
|
|
||||||
// Avoid including windows.h (https://stackoverflow.com/a/30741042)
|
// Avoid including windows.h (https://stackoverflow.com/a/30741042)
|
||||||
|
#if defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
|
||||||
|
extern "C" __declspec(dllimport) void __stdcall OutputDebugStringW(const wchar_t *lpOutputString);
|
||||||
|
#else
|
||||||
extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char *lpOutputString);
|
extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char *lpOutputString);
|
||||||
|
#endif
|
||||||
extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();
|
extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();
|
||||||
|
|
||||||
namespace spdlog {
|
namespace spdlog {
|
||||||
@@ -38,8 +45,14 @@ protected:
|
|||||||
}
|
}
|
||||||
memory_buf_t formatted;
|
memory_buf_t formatted;
|
||||||
base_sink<Mutex>::formatter_->format(msg, formatted);
|
base_sink<Mutex>::formatter_->format(msg, formatted);
|
||||||
formatted.push_back('\0'); // add a null terminator for OutputDebugStringA
|
formatted.push_back('\0'); // add a null terminator for OutputDebugString
|
||||||
|
#if defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
|
||||||
|
wmemory_buf_t wformatted;
|
||||||
|
details::os::utf8_to_wstrbuf(string_view_t(formatted.data(), formatted.size()), wformatted);
|
||||||
|
OutputDebugStringW(wformatted.data());
|
||||||
|
#else
|
||||||
OutputDebugStringA(formatted.data());
|
OutputDebugStringA(formatted.data());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void flush_() override {}
|
void flush_() override {}
|
||||||
|
Reference in New Issue
Block a user