Reputation: 6448
I'm using the latest code checked out from GitHub. (0.13.0 beta)
I'm developing for Android with Eclipse. I did added *COCOS2D_DEBUG* in Android.mk. I checked and made sure that COCOS2D_DEBUG was indeed defined with the value of 1.
Problem: CCLog won't print anything to the LogCat. In the meantime, CCMessageBox works well.
(I then tested the same set of code on iOS, both CCLog and CCMessageBox work well.)
What am I missing here?
Upvotes: 5
Views: 6610
Reputation: 1870
As of cocos2dx version 3 at least in Application.mk COCOS2D_DEBUG is set conditionally based on standard NDK flag NDK_DEBUG=1. So just invoke your builds passing
ndk-build NDK_DEBUG=1
This also insures that the appropriate symbols are generated for a debug build. You will want to use the macro "CCLOG" and not the deprecated function call CCLog as the former will expand to nothing in release mode and not incur any performance overhead when building for release.
Upvotes: 0
Reputation: 159
I add the same problem : logcat was not showing my cocos2dx logs. Then I understood that my application was always built in release mode.
Make sure to activate debug mode in Eclipse for your project:
- Right-click your project
- Choose "Build Configurations" \ "Set Active" \ "Debug"
No need to modify your application.mk, since a directive is already set there for debugging or for running a release version... After that to get logs in logcat window,
- Create a new LogCat's filter and in the "by log tag" type
"cocos2d-x debug info" (without quotes)
When running your application, choose your filter in LogCat to view everything. BTW: use the CCLOG macro when using cocos2dx logs:
CCLOG("Year is %d",2015); // don't use CCLog
Upvotes: 0
Reputation: 535
My own experience on how to use CCLOG to print info in Eclipse's LogCat:
in Eclipse, your project open jni folder, add -DCCOCOS2D_DEBUG=1 in Application.mk file like this:
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++1 -fsigned-char -DCCOCOS2D_DEBUG=1
All of these functions CCLOG CCLog log, works, so use just the main one CCLOG...
Notes:
I have commented
//#define COCOS2D_DEBUG 1
in my project, made sure that there is no such other line and I still get my CCLOG printed out in visual studio 2013, and Eclipse's Logcat on windows 7:
Upvotes: 0
Reputation: 8896
If you want to use "CCLog()" then there is need not to be set #define COCOS2D_DEBUG 1 If you want to use CCLOG() then you have to set #define COCOS2D_DEBUG 1
ex for CCLog
CClog("Hi this is CCLog");
Sample code for CCLOG
CCLOG ("Characters: %c %c \n", 'a', 65);
CCLOG ("Decimals: %d %ld\n", 1977, 650000L);
CCLOG ("Preceding with blanks: %10d \n", 1977);
CCLOG ("Preceding with zeros: %010d \n", 1977);
CCLOG ("Some different radixes: %d %x %o %#x %#o \n", 100, 100, 100, 100, 100);
CCLOG ("floats: %4.2f %+.0e %E \n", 3.1416, 3.1416, 3.1416);
CCLOG ("Width trick: %*d \n", 5, 10);
CCLOG ("%s \n", "A string");
Upvotes: 0
Reputation: 11930
Use CCLOG("Test String"), all upper case, it will work. CCLog("Hello") don ´t work in eclipse log cat.
Upvotes: 5
Reputation: 3182
Just wondering two thing: 1. are you using CCLog or CCLOG (all big case)?
did you put
#define COCOS2D_DEBUG 1
at the really top (higher than any #include) in the cpp file that you wanna debug?
Upvotes: 7