Support Android logging.

This commit is contained in:
Alex Shvartzkop 2024-02-11 04:00:10 +03:00
parent 04cbeb0f8a
commit 85cc2acd6f

View file

@ -39,6 +39,10 @@
#include "wx/msw/private.h"
#endif
#if defined(__ANDROID__)
#include <android/log.h>
#endif
// ===========================================================================
// implementation
// ===========================================================================
@ -143,8 +147,13 @@ wxMessageOutputStderr::wxMessageOutputStderr(FILE *fp, const wxMBConv& conv)
void wxMessageOutputStderr::Output(const wxString& str)
{
const wxCharBuffer& buf = PrepareForOutput(str);
#if defined(__ANDROID__)
__android_log_write(ANDROID_LOG_INFO, "wxWidgets", buf.data());
#else
fwrite(buf, buf.length(), 1, m_fp);
fflush(m_fp);
#endif
}
// ----------------------------------------------------------------------------
@ -158,6 +167,10 @@ void wxMessageOutputDebug::Output(const wxString& str)
out.Replace(wxT("\t"), wxT(" "));
out.Replace(wxT("\n"), wxT("\r\n"));
::OutputDebugString(out.t_str());
#elif defined(__ANDROID__)
const wxCharBuffer& buf = PrepareForOutput(str);
__android_log_write(ANDROID_LOG_DEBUG, "wxWidgets", buf.data());
#else
// TODO: use native debug output function for the other ports too
wxMessageOutputStderr::Output(str);