How to display NX_PRINTF logs in debug builds?
How can I modify the `mediaserver_stderr.log` file to not display the NX_PRINTF logs after compiling and debugging the library in the latest NX_SDK?
-
Hi
I think you're saying NX_PRINT, as we don't have NX_PRINTF method.
If you check the SDK, then looking at
nx_kit/src/nx/kit/debug.handdebug.cpp:-
NX_PRINT(and everything built on it, ex:NX_PRINT_VALUE,NX_PRINT_HEX_DUMP, assertion failures) writes unconditionally tonx::kit::debug::stream(), which defaults tostd::cerr -
NX_OUTPUTis the toggleable version — it only printsif (NX_DEBUG_ENABLE_OUTPUT), which by default resolves toini().enableOutput.
So if your debug statements use
NX_PRINTdirectly (or macros derived from it), turning off any "debug" flag won't help — they always fire.Option 1 - use the built-in
enableOutputswitch (recommended)If your logging goes through
NX_OUTPUT(via theEngine/ConsumingDeviceAgentbase classes innx/sdk/analytics/helpers/), it's already gated by a constructor flag. In the sample plugin this is hardcoded on:// engine.cpp Engine::Engine(): nx::sdk::analytics::Engine(/*enableOutput*/ true) // <-- flip to false { }// device_agent.cpp ConsumingDeviceAgent(deviceInfo, /*enableOutput*/ true) // <-- flip to falseSetting these to
false(or driving them from your own build config /.iniflag) silences allNX_OUTPUTcalls without touching source elsewhere.Option 2 — Strip or guard your
NX_PRINTcallsSince
NX_PRINTis unconditional by design (it's meant for things you always want logged, like errors), the clean fix for pure debugging prints is to remove them before shipping, or wrap them yourself:#ifdef MY_PLUGIN_DEBUG_LOGGING NX_PRINT << "some debug value: " << value; #endifand simply don't define
MY_PLUGIN_DEBUG_LOGGINGin your release build.Note for
IniConfigIf your plugin defines its own
.ini(vianx::kit::IniConfig), double-check it isn't shipping withenableOutput=truewritten into the.inifile in your output directory —IniConfig::reload()will re-enable output from that file even if your constructor default isfalse. Set/lock it tofalsethere too, or disable.inireading for the release build (IniConfighas an option to freeze values instead of reloading — seeini_config.h).For a quick fix, do Option 1 for anything going through the
Engine/ConsumingDeviceAgenthelpers, and grep your plugin for rawNX_PRINT/LL/NX_PRINT_VALUEcalls you added while debugging and delete.0 -
Please sign in to leave a comment.
Comments
1 comment