Open bspinner opened 4 years ago
Doing something like this could be a solution
#ifdef ANDROID
#include <android/log.h>
#define write_log(...) __android_log_print(ANDROID_LOG_INFO, "WRITELOG", __VA_ARGS__)
#else
extern void write_log (const TCHAR *,...);
#endif
but with above's code write_logfile
setting isn't respected
The current version of write_log
is as follows:
void write_log(const char* format, ...)
{
if (write_logfile)
{
// Redirect logging to Android's logcat
#ifdef ANDROID
va_list parms;
va_start(parms, format);
SDL_Log(format, parms);
va_end(parms);
#else
TCHAR buffer[WRITE_LOG_BUF_SIZE];
va_list parms;
va_start(parms, format);
auto count = vsnprintf(buffer, WRITE_LOG_BUF_SIZE - 1, format, parms);
if (debugfile)
{
fprintf(debugfile, "%s", buffer);
fflush(debugfile);
}
va_end(parms);
#endif
}
}
If you added your suggested block inside the existing ifdef ANDROID
block, it would also respect the setting.
As of now, the
write_log
redirection toSDL_Log
leads to crashes and will be removed soon (writing to logfile works now). Logcat output might be interesting in the future for proper crashlogs from users.