Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix windows event sink log compilation error with UNICODE preprocessor #1760

Merged
merged 5 commits into from
Dec 16, 2020

Conversation

iko1
Copy link

@iko1 iko1 commented Dec 13, 2020

No description provided.

@gabime
Copy link
Owner

gabime commented Dec 13, 2020

You got me confused. I see you removed the #ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
So what's the purpose of this pr ?

@iko1
Copy link
Author

iko1 commented Dec 14, 2020

I updated this PR. I'm using #ifdef to check if SPDLOG_WCHAR_TO_UTF8_SUPPORT and then convert the message accordingly before calling to UNICODE version of ReportEvent.

auto succeeded = ::ReportEvent(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);
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
auto buf = std::wstring_convert<std::codecvt_utf8<wchar_t>>().from_bytes(formatted.data());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::wstring_convert<std::codecvt_utf8> is deprecated. Please use details::os::wstr_to_utf8buf(..) instead. See usage example here.

}

throw_spdlog_ex(fmt::format("WideCharToMultiByte failed. Last error: {}", ::GetLastError()));
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong error message in exception. should be “ MultiByteToWideChar”

@iko1 iko1 requested a review from gabime December 16, 2020 04:57
@gabime gabime merged commit 17c6e6e into gabime:v1.x Dec 16, 2020
@davinci26 davinci26 mentioned this pull request Mar 23, 2021
bachittle pushed a commit to bachittle/spdlog that referenced this pull request Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants