21

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?

frogatto
  • 28,539
  • 11
  • 83
  • 129
Victor S
  • 4,021
  • 15
  • 43
  • 54

4 Answers4

55

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

Usman Kurd
  • 7,212
  • 7
  • 57
  • 86
2

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.

Usman Kurd
  • 7,212
  • 7
  • 57
  • 86
BonderWu
  • 133
  • 1
  • 10
0

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);".

Tarun Chawla
  • 508
  • 4
  • 17
0

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 !


cigien
  • 57,834
  • 11
  • 73
  • 112