Repository navigation
Description
Tracking the TODO in packages/host/cpp/Logger.cpp.
react-native-node-api/packages/host/cpp/Logger.cpp
Lines 66 to 72 in 29a527d
| void log_debug(const char *format, ...) { | |
| // TODO: Disable logging in release builds | |
| va_list args; | |
| va_start(args, format); | |
| log_message_internal(LogLevel::Debug, format, args); | |
| va_end(args); | |
| } |
log_debug formats and emits unconditionally — there is no build-configuration guard anywhere in Logger.cpp. The host calls it on every addon load: per-library "Found napi_register_module_v1", per-library "Failed to find…", and the resolution chatter in CxxNodeApiHostModule.cpp. In a shipped app that is per-addon logging to logcat / os_log that no user asked for, plus the string formatting cost on a path that runs during startup.
Two things to decide:
- What "release" means here.
NDEBUGis the obvious hook and is set by the CMakeRelease/MinSizeRelconfigurations, butRelWithDebInfoalso defines it — which may or may not be what we want given SupportRelWithDebInfoin CMake RN #255. React Native's ownNDEBUG/__DEV__split is worth mirroring rather than inventing something. - Compile out vs. gate at runtime. Compiling the body away removes the formatting cost entirely; a runtime level check keeps the ability to turn logging on when diagnosing a release-only problem — which, given that release-mode issues are the hard ones, has real value. A compile-time default with a runtime override is the usual compromise.
log_warning and log_error should keep firing in release regardless.
Also a prerequisite for making release-mode CI runs readable — see the iOS Release-mode CI issue.
Activity
ci: fix host-cpp-tests label check to match the actual "Host 🏡" label
docs: correct the host label name to "Host 🏡"
docs: instruct Claude Code to attach CI labels when opening PRs (#436)
fix(host): compile out log_debug in release (NDEBUG) builds
ci: fix host-cpp-tests label check to match the actual "Host 🏡" label
Drop the host's shadowing implementations of runtime Node-API functio…
fix(host): compile out log_debug in release (NDEBUG) builds (callstac…
Drop the host's shadowing implementations of runtime Node-API functio…
fix(host): compile out log_debug in release (NDEBUG) builds (#431)
fix(host): compile out log_debug in release (NDEBUG) builds (#431)
Drop the host's shadowing implementations of runtime Node-API functio…
Drop the host's shadowing implementations of runtime Node-API functio…
Drop the host's shadowing implementations of runtime Node-API functio…
Drop the host's shadowing implementations of runtime Node-API functio…
Drop the host's shadowing implementations of runtime Node-API functio…