====NDK==== ===stringstream et __android_log_print=== Avec une adaptation pour les cas non Android. #ifdef __ANDROID__ #include #include class MyStream { private: std::stringstream m_ss; int m_logLevel; public: MyStream(int Xi_logLevel) { m_logLevel = Xi_logLevel; }; ~MyStream() { __android_log_print(m_logLevel, LOG_TAG, "%s", m_ss.str().c_str()); } template MyStream& operator<<(T&& Xi_val) { m_ss << std::forward(Xi_val); return *this; } }; #define MY_LOG(LOG_LEVEL) MyStream(ANDROID_LOG_##LOG_LEVEL) #else #include enum LogPriority { LOG_UNKNOWN = 0, LOG_DEFAULT, LOG_VERBOSE, LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR, LOG_FATAL, LOG_SILENT }; #define MY_LOG(LOG_LEVEL) (LOG_##LOG_LEVEL <= LOG_INFO ? std::cout : std::cerr) #endif [[https://stackoverflow.com/questions/8870174/is-stdcout-usable-in-android-ndk|Is "std::cout" usable in Android-ndk]] {{ :lang:android:log:c_-_is_std_cout_usable_in_android-ndk_-_stack_overflow_30_01_2023_09_50_35_.html |Archive du 15/01/2012 le 30/01/2023}}