Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to enable ALOGD in android?

In CPP code, for ex in camera HAL, ALOGD messages are not being printed. Like in set_preview_window() ALOGD("set_preview_window : X, rc %d", rc); How to enable them?

like image 891
Ravi Chandra Avatar asked Nov 13 '13 05:11

Ravi Chandra


2 Answers

try to add following statements in the files which you wanted to catch logs.

#define LOG_NDEBUG 0
#define LOG_NIDEBUG 0
#define LOG_NDDEBUG 0

After compiled, you can try to get logs through adb logcat.

like image 90
南山怀槿 Avatar answered Oct 06 '22 22:10

南山怀槿


These macros (ALOGX...) are defined in some system core C/C++ headers. You can find an example in system/core/include/log/log.h (AOSP 6.0.0r1)

Sometimes you need to add liblog in LOCAL_SHARED_LIBRARIES of the corresponding Android.mk :

LOCAL_SHARED_LIBRARIES := ... liblog

Also, you might need to add two lines at the top of C/C++ concerned source files :

 #define LOG_NDEBUG 0
 #define LOG_TAG "LibName"

Don't forget LOG_NDEBUG 0 if you want ALOGV() logs. After rebuilding the lib/module, you should be able to see logs in your logcat.

like image 27
vhamon Avatar answered Oct 06 '22 23:10

vhamon