android: Send nout to Android log, don't duplicate output to stderr

This commit is contained in:
rdb 2021-12-06 22:24:36 +01:00
parent 9dad304f85
commit 396e623aba
3 changed files with 13 additions and 4 deletions

View File

@ -92,7 +92,7 @@ overflow(int ch) {
*/
void AndroidLogStream::AndroidLogStreamBuf::
write_char(char c) {
nout.put(c);
//nout.put(c);
if (c == '\n') {
// Write a line to the log file.
__android_log_write(_priority, _tag.c_str(), _data.c_str());

View File

@ -44,10 +44,10 @@ private:
std::string _data;
};
AndroidLogStream(int priority);
public:
AndroidLogStream(int priority);
virtual ~AndroidLogStream();
static std::ostream &out(NotifySeverity severity);
};

View File

@ -31,6 +31,8 @@
#ifdef ANDROID
#include <android/log.h>
#include "androidLogStream.h"
#endif
using std::cerr;
@ -345,8 +347,9 @@ assert_failure(const char *expression, int line,
#ifdef ANDROID
__android_log_assert("assert", "Panda3D", "Assertion failed: %s", message.c_str());
#endif
#else
nout << "Assertion failed: " << message << "\n";
#endif
// This is redefined here, shadowing the defining in config_prc.h, so we can
// guarantee it has already been constructed.
@ -477,6 +480,12 @@ config_initialized() {
}
#endif // BUILD_IPHONE
}
#ifdef ANDROID
} else {
// By default, we always redirect the notify stream to the Android log.
Notify *ptr = Notify::ptr();
ptr->set_ostream_ptr(new AndroidLogStream(ANDROID_LOG_INFO), true);
#endif
}
}
}