debug and logging


#1

Hi,

Need to know how should i debug and log the messages on the console.

How can i display string variable in the debug log?

Thanks.


CCLOG is not working on android
#2

Of course you can. Search “CCLOG” in the project source for sample usages.
Just like

CCLOG("FilePath = %s", path.c_str(),

It will output to the logcat window, not console window.

And don’t forget to define COCOS_DEBUG = 1 or 2 to enable CCLOG output, otherwise it will keep silence to improve the efficiency


#3

where i have to setup this for android?

it doesn’t work with LOCAL_CFLAGS += -DCOCOS2D_DEBUG=2 in the makefile.


#4

I had problems also with putting -DCOCOS2D_DEBUG=1 in the makefile.
I worked around the issue by simply using a define at the beginning of the C++ source file I want to see logs in:
#define COCOS2D_DEBUG 1
Make sure you put the define before including cocos2d.h (the best is to put it before all the #include directives).
I know it is not a good solution but it works for sure.


#5

Hi,
I just add LOCAL_CFLAGS += ~~DCOCOS2D_DEBUG=1 in jni//Android.mk and CCLog works ok.
LOCAL_PATH := $
include $
LOCAL_MODULE := cocosLink
LOCAL_CFLAGS +=~~DCOCOS2D_DEBUG=1 <- add here

LOCAL_SRC_FILES := main.cpp
check log in logcat.


#6

Need to add @ APP_CPPFLAGS *= ~~DCOCOS2D_DEBUG=1@ into jni/Application.mk in my case.
Splash Huang wrote:

Hi,
I just add LOCAL_CFLAGS +=~~DCOCOS2D_DEBUG=1 in jni//Android.mk and CCLog works ok.
>
LOCAL_PATH := $
include $
LOCAL_MODULE := cocosLink
>
LOCAL_CFLAGS*= DCOCOS2D_DEBUG=1 < add here
>
LOCAL_SRC_FILES := main.cpp >
check log in logcat.


#7

How do you get logs in the console ?