I added
#define LOG_NDEBUG 0
#define LOG_TAG "StagefrightMediaScanner"
#include <utils/Log.h>
in the libstagefright/StagefrightMediaScanner.cpp
but can not print anything using LOGV and LOGE, does any other things can I need to do?
I added
#define LOG_NDEBUG 0
#define LOG_TAG "StagefrightMediaScanner"
#include <utils/Log.h>
in the libstagefright/StagefrightMediaScanner.cpp
but can not print anything using LOGV and LOGE, does any other things can I need to do?
You can use the following code to get Log
__android_log_print(ANDROID_LOG_ERROR, "TRACKERS", "%s", Str);
and add the following header file
#include <android/log.h>
Additional docs are here: https://developer.android.com/ndk/reference/group/logging
You can check frameworks/av/media/libstagefright/Android.mk, whether there is
LOCAL_SHARED_LIBRARIES += liblog
in it.
Then, under frameworks/av/media/libstagefright/
$ mm
$ adb push $OUT/system/lib/libstagefright.so /system/lib/
$ adb shell killall mediaserver
Then reboot your phone or am start a MEDIA_MOUNTED
intent, MediaScanner will work, and the logs you just added(either ALOGE/ALOGV
or LOGE/LOGV
) should be shown.
No you have done right. Just check it whether you are using ALOGV() which is similar to printf(),if you want to print a integer with a log then you can write like this :" ALOGV("Integer is %d",integer);".
TestLog.cpp
{
#define LOG_VERBOSE(message, ...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, "MY_LOG_TAG", "[%s %s] " message, __FILE_NAME__, __func__, ##__VA_ARGS__))
void logFunction1() {
char *testStatus = "Success";
LOG_VERBOSE("This is my log, Status : %s", testStatus);
logFunction2();
}
void logFunction2() {
LOG_VERBOSE("Hope this is helpful !");
}
}
output :
V [TestLog.cpp logFunction1] This is my log, Status : Success
V [TestLog.cpp logFunction2] Hope this is helpful !