1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 17:28:50 -05:00

Check for errors when writing to log

This commit is contained in:
Jon Beniston 2023-01-02 15:24:17 +00:00
parent eb9fb3469d
commit 526164f2e1

View File

@ -189,25 +189,29 @@ void Android::messageHandler(QtMsgType type, const QMessageLogContext& context,
}
const char * const local = report.toLocal8Bit().constData();
const char * const applicationName = "sdrangel";
int ret;
switch (type)
{
case QtDebugMsg:
__android_log_write(ANDROID_LOG_DEBUG, applicationName, local);
ret = __android_log_write(ANDROID_LOG_DEBUG, applicationName, local);
break;
case QtInfoMsg:
__android_log_write(ANDROID_LOG_INFO, applicationName, local);
ret = __android_log_write(ANDROID_LOG_INFO, applicationName, local);
break;
case QtWarningMsg:
__android_log_write(ANDROID_LOG_WARN, applicationName, local);
ret = __android_log_write(ANDROID_LOG_WARN, applicationName, local);
break;
case QtCriticalMsg:
__android_log_write(ANDROID_LOG_ERROR, applicationName, local);
ret = __android_log_write(ANDROID_LOG_ERROR, applicationName, local);
break;
case QtFatalMsg:
default:
__android_log_write(ANDROID_LOG_FATAL, applicationName, local);
ret = __android_log_write(ANDROID_LOG_FATAL, applicationName, local);
abort();
}
if (ret < 0) {
__android_log_write(ANDROID_LOG_ERROR, applicationName, "Error writing to log");
}
}
#endif // ANDROID