diff --git a/dtool/src/prc/androidLogStream.cxx b/dtool/src/prc/androidLogStream.cxx index ef05db96ee..938f5badaa 100644 --- a/dtool/src/prc/androidLogStream.cxx +++ b/dtool/src/prc/androidLogStream.cxx @@ -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()); diff --git a/dtool/src/prc/androidLogStream.h b/dtool/src/prc/androidLogStream.h index aa50c8d7af..f8d2dae034 100644 --- a/dtool/src/prc/androidLogStream.h +++ b/dtool/src/prc/androidLogStream.h @@ -44,10 +44,10 @@ private: std::string _data; }; - AndroidLogStream(int priority); - public: + AndroidLogStream(int priority); virtual ~AndroidLogStream(); + static std::ostream &out(NotifySeverity severity); }; diff --git a/dtool/src/prc/notify.cxx b/dtool/src/prc/notify.cxx index 791f2216ee..2c1b737ddb 100644 --- a/dtool/src/prc/notify.cxx +++ b/dtool/src/prc/notify.cxx @@ -31,6 +31,8 @@ #ifdef ANDROID #include + +#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 } } }