mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-27 23:08:47 +00:00
Common: Migrate logging to fmt
Continues the migration of our code over to the fmt logger.
This commit is contained in:
parent
4f5c8bb42a
commit
4e8df93f41
18 changed files with 154 additions and 152 deletions
|
@ -179,7 +179,7 @@ std::string StringFromFormatV(const char* format, va_list args)
|
|||
#endif
|
||||
if (vasprintf(&buf, format, args) < 0)
|
||||
{
|
||||
ERROR_LOG(COMMON, "Unable to allocate memory for string");
|
||||
ERROR_LOG_FMT(COMMON, "Unable to allocate memory for string");
|
||||
buf = nullptr;
|
||||
}
|
||||
|
||||
|
@ -442,24 +442,22 @@ std::wstring CPToUTF16(u32 code_page, std::string_view input)
|
|||
|
||||
std::string UTF16ToCP(u32 code_page, std::wstring_view input)
|
||||
{
|
||||
std::string output;
|
||||
if (input.empty())
|
||||
return {};
|
||||
|
||||
if (0 != input.size())
|
||||
// "If cchWideChar [input buffer size] is set to 0, the function fails." -MSDN
|
||||
auto const size = WideCharToMultiByte(code_page, 0, input.data(), static_cast<int>(input.size()),
|
||||
nullptr, 0, nullptr, nullptr);
|
||||
|
||||
std::string output(size, '\0');
|
||||
|
||||
if (size != WideCharToMultiByte(code_page, 0, input.data(), static_cast<int>(input.size()),
|
||||
output.data(), static_cast<int>(output.size()), nullptr, nullptr))
|
||||
{
|
||||
// "If cchWideChar [input buffer size] is set to 0, the function fails." -MSDN
|
||||
auto const size = WideCharToMultiByte(
|
||||
code_page, 0, input.data(), static_cast<int>(input.size()), nullptr, 0, nullptr, nullptr);
|
||||
|
||||
output.resize(size);
|
||||
|
||||
if (size != WideCharToMultiByte(code_page, 0, input.data(), static_cast<int>(input.size()),
|
||||
&output[0], static_cast<int>(output.size()), nullptr, nullptr))
|
||||
{
|
||||
const DWORD error_code = GetLastError();
|
||||
ERROR_LOG(COMMON, "WideCharToMultiByte Error in String '%s': %lu",
|
||||
std::wstring(input).c_str(), error_code);
|
||||
output.clear();
|
||||
}
|
||||
const DWORD error_code = GetLastError();
|
||||
ERROR_LOG_FMT(COMMON, "WideCharToMultiByte Error in String '{}': {}", WStringToUTF8(input),
|
||||
error_code);
|
||||
return {};
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@ -508,7 +506,7 @@ std::string CodeTo(const char* tocode, const char* fromcode, std::basic_string_v
|
|||
iconv_t const conv_desc = iconv_open(tocode, fromcode);
|
||||
if ((iconv_t)-1 == conv_desc)
|
||||
{
|
||||
ERROR_LOG(COMMON, "Iconv initialization failure [%s]: %s", fromcode, strerror(errno));
|
||||
ERROR_LOG_FMT(COMMON, "Iconv initialization failure [{}]: {}", fromcode, strerror(errno));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -541,7 +539,7 @@ std::string CodeTo(const char* tocode, const char* fromcode, std::basic_string_v
|
|||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(COMMON, "iconv failure [%s]: %s", fromcode, strerror(errno));
|
||||
ERROR_LOG_FMT(COMMON, "iconv failure [{}]: {}", fromcode, strerror(errno));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue