summaryrefslogtreecommitdiff
path: root/indra/llcommon/llapr.cpp
diff options
context:
space:
mode:
authorAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2026-07-25 02:38:49 +0300
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2026-07-27 20:29:35 +0300
commite5fbe49ff74f09d6cd982764e7913086e8825423 (patch)
treead10c764124aec990fea03c3d078462a90c6031f /indra/llcommon/llapr.cpp
parentcf74ead7ad7eec40edb2d01c52bc3994c3850bd0 (diff)
#6040 Make apr warnings easier to understand
Diffstat (limited to 'indra/llcommon/llapr.cpp')
-rw-r--r--indra/llcommon/llapr.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp
index eeff2694a7..06eb4c389f 100644
--- a/indra/llcommon/llapr.cpp
+++ b/indra/llcommon/llapr.cpp
@@ -231,9 +231,35 @@ bool _ll_apr_warn_status(apr_status_t status, const char* file, int line)
{
if(APR_SUCCESS == status) return false;
#if !LL_LINUX
- char buf[MAX_STRING]; /* Flawfinder: ignore */
+ char buf[MAX_STRING];
apr_strerror(status, buf, sizeof(buf));
- LL_WARNS("APR") << "APR: " << file << ":" << line << " " << buf << LL_ENDL;
+
+#ifdef LL_WINDOWS
+ // On Windows, APR error strings may be in the system's ANSI code page (e.g., Cyrillic)
+ // Convert to UTF-8 for proper logging
+ std::string error_msg = buf;
+ int wlen = MultiByteToWideChar(CP_ACP, 0, buf, -1, nullptr, 0);
+ if (wlen > 0)
+ {
+ std::wstring wbuf(wlen, L'\0');
+ MultiByteToWideChar(CP_ACP, 0, buf, -1, &wbuf[0], wlen);
+
+ int utf8len = WideCharToMultiByte(CP_UTF8, 0, wbuf.c_str(), -1, nullptr, 0, nullptr, nullptr);
+ if (utf8len > 0)
+ {
+ std::string utf8buf(utf8len, '\0');
+ WideCharToMultiByte(CP_UTF8, 0, wbuf.c_str(), -1, &utf8buf[0], utf8len, nullptr, nullptr);
+ error_msg = utf8buf.c_str(); // Remove null terminator
+ }
+ LL_WARNS("APR") << "APR: " << file << ":" << line << " " << error_msg << " (0x" << std::hex << status << std::dec << ")" << LL_ENDL;
+ }
+ else
+ {
+ LL_WARNS("APR") << "APR: " << file << ":" << line << " " << buf << " (0x" << std::hex << status << std::dec << ")" << LL_ENDL;
+ }
+#else
+ LL_WARNS("APR") << "APR: " << file << ":" << line << " " << buf << " (0x" << std::hex << status << std::dec << ")" << LL_ENDL;
+#endif
#endif
return true;
}