If you are building localy use DEBUG_BUILD=y and add
void debug_output_(const char *p)
{
static boolean once = false;
if (!once)
{
once = true;
Serial1.begin(115200); // You can choose where the debug goes
}
Serial1.print(p);
}
in you application.cpp.
Then add all the DEBUG("connection closed %d 0x%04x",retValue, address);
you want.
You get to leave em all in and in a release build they are automagically removed!
Happy debugging!
If you have an JTAG add USE_SWO_JTAG=y too!
See for details