Removed SPDLOG_WCHAR_TO_UTF8_SUPPORT

This commit is contained in:
gabime
2023-07-28 17:15:10 +03:00
parent 11ddcb2e91
commit d94830814f
10 changed files with 6 additions and 240 deletions

View File

@@ -6,20 +6,13 @@
#if defined(_WIN32)
# 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 <mutex>
# include <string>
// 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);
# endif
extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();
namespace spdlog {
@@ -45,13 +38,7 @@ protected:
memory_buf_t formatted;
base_sink<Mutex>::formatter_->format(msg, formatted);
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());
# endif
}
void flush_() override {}

View File

@@ -236,18 +236,9 @@ protected:
base_sink<Mutex>::formatter_->format(msg, formatted);
formatted.push_back('\0');
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
wmemory_buf_t buf;
details::os::utf8_to_wstrbuf(string_view_t(formatted.data(), formatted.size()), buf);
LPCWSTR lp_wstr = buf.data();
succeeded = static_cast<bool>(::ReportEventW(event_log_handle(), eventlog::get_event_type(msg), eventlog::get_event_category(msg),
event_id_, current_user_sid_.as_sid(), 1, 0, &lp_wstr, nullptr));
#else
LPCSTR lp_str = formatted.data();
succeeded = static_cast<bool>(::ReportEventA(event_log_handle(), eventlog::get_event_type(msg), eventlog::get_event_category(msg),
event_id_, current_user_sid_.as_sid(), 1, 0, &lp_str, nullptr));
#endif
if (!succeeded)
{