How do I disable logs in my game?

I want to know how to tell creator not to output logs anymore…I tried…

cc.debug.DebugMode = cc.debug.DebugMode.NONE;

and put a console.log statement after it but the engine was still printing the logs. please guide.

thanks!

Why do you not want logs outputting in a debug version?

hi,
actually I wanted a way to display logs in the simulator or debug mode but not in release mode. for that:

if (CC_DEBUG) {
console.log(“test”);
}
this will not display test in release mode on the device and will display test everywhere else.
Thanks!

you can try like this:

if (!CC_DEBUG) {
console.log = function(){};
console.error= function(){};

}

put this in your start script somewhere

hi,
if I am not wrong, when CC_DEBUG is false, ie in release mode, console.log and console.error don’t function to begin with. so there is no need for redefining them for that case.
thanks!

In my experience, if you use cc.log instead of console.log, it won’t produce any output in release build.

2 Likes