For Eclipse, CCLog doesn't work. CCMessageBox works well
Asked Answered
D

6

5

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?

Decolonize answered 25/4, 2012 at 8:7 Comment(0)
S
7

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?

Sidesaddle answered 29/5, 2012 at 10:48 Comment(0)
C
5

Use CCLOG("Test String"), all upper case, it will work. CCLog("Hello") don ´t work in eclipse log cat.

Coronograph answered 1/6, 2012 at 12:29 Comment(1)
Wow Thanks, i didn´t see logs and it was, i must to ise CCLog.Boyish
K
0

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");
Kopans answered 9/11, 2013 at 7:11 Comment(0)
M
0

My own experience on how to use CCLOG to print info in Eclipse's LogCat:

  1. 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

Application.mk with -DCCOCOS2D_DEBUG=1

  1. Somewhere in your project cpp files write CCLOG function: enter image description here

All of these functions CCLOG CCLog log, works, so use just the main one CCLOG...

  1. Eclipse's LogCat is a Terrible tool in my experience, I hate it so much.. Very annoying thing that keeps happening is that after 3-6 builds LogCat stops working, new lines stop appearing, and so I have to restart Eclipse and then LogCat continues working... When I press Clear Log button in LogCat then all the logs disappears and new ones doesn't appear...
    Anyways, to see the logs add a filter first, name doesn't matter, and in tag line write: debug info , then the CCLOGs will show up: LogCat 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:

visual studio2013 COCOS2D_DEBUG commented out

Maniac answered 10/10, 2014 at 8:5 Comment(0)
A
0

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
Alysiaalyson answered 30/1, 2015 at 13:22 Comment(0)
D
0

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.

Delwin answered 7/2, 2016 at 5:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.