gps: route GPS_DEBUG diagnostics through a LOG_DEBUG_GPS() macro - #11414
Conversation
Replaces 27 log-only #ifdef GPS_DEBUG blocks across GPS.cpp,
PositionModule, MeshService, and GPSStatus.h with a single-line
LOG_DEBUG_GPS() call (src/gps/GPSLog.h, modeled on LOG_MIGRATION:
value-gated, ((void)0) when off). Blocks containing declarations,
control flow, hexDump, or nested conditionals keep an explicit
'#if GPS_DEBUG' guard. RTC.cpp's per-reading raw time dumps and
per-candidate rejection chatter fold under the same gate; quality
transitions and boot-time seeding stay at debug.
Also fixes the '// define GPS_DEBUG' missing-# typo in two variant
headers and updates all seven commented examples to the value form
('#define GPS_DEBUG 1') required by the value-based gate.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1
⚡ Try this PR in the Web FlasherNote Building this pull request… the flash button, badges and supported-board |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (14)
📝 WalkthroughWalkthroughThe PR adds the ChangesGPS diagnostic logging
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
377370b
into
claude/meshtastic-logging-trace-gate
… drop redundant logs (meshtastic#11391) * logging: gate LOG_TRACE behind MESHTASTIC_TRACE_LOGGING, drop redundant reclock logs LOG_TRACE now compiles out by default so trace-level diagnostics cost no flash; enable with -DMESHTASTIC_TRACE_LOGGING. Portduino keeps it on for the traceFilename packet-trace feature. Remove the 66 caller-side I2C reclock/restore log lines in the telemetry sensors: ReClockI2C::setClock/restoreClock already log both frequencies internally (now at trace level, since they fire every sensor read). Also unify near-duplicate literals (colon/case/punctuation variants) so linker string dedup applies, and drop an information-free bare 'done'. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1 * logging: demote chatty per-packet/per-poll DEBUG lines to trace level With LOG_TRACE compiled out by default, per-iteration chatter (packet bookkeeping, sensor poll values, e-ink refresh reasons, GPS pin states, UI runState traces) now costs no flash on device builds while remaining one -DMESHTASTIC_TRACE_LOGGING away. 108 lines demoted, 4 information- free lines removed; failure paths, drop reasons, and one-time init logs all stay at debug level. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1 * logging: address CodeRabbit review on trace-gate PR - GPS: pass serial-derived buffers as %s args, never as format strings (untrusted bytes could contain % directives) - 0x%08x for packet id / NodeNum per convention (Router, CannedMessage, NeighborInfo); unsigned casts for size_t args; %u for uint32_t delta - EInk: async full-refresh begin/complete back to DEBUG (rare state transitions); per-frame SKIPPED lines stay trace Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1 * logging: gate trace on the flag's value, not its presence -DMESHTASTIC_TRACE_LOGGING=0 previously *enabled* trace logging because the gate tested definedness. The flag now defaults per-platform (portduino 1, else 0) and both backends test the value, so =0 disables, =1 or a bare -D enables. Also cast tx_after-millis() to uint32_t for %u (millis() is unsigned long on native). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1 * logging: clang-format rewrap after specifier widening Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1 * Even fewer bytes! * logging: keep compile-gated debug lines at debug level; fix native-suite-count Lines already inside default-off #ifdef blocks (GPS_DEBUG, DEBUG_LOOP_TIMING) cost no flash and should stay visible at debug level when their gate is enabled, rather than also requiring MESHTASTIC_TRACE_LOGGING. test/native-suite-count lags the two test_event_channel_* suites added by meshtastic#11045 (develop's Native Suite Count check has the same mismatch); bump 46 -> 47. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1 * gps: route GPS_DEBUG diagnostics through a LOG_DEBUG_GPS() macro (meshtastic#11414) Replaces 27 log-only #ifdef GPS_DEBUG blocks across GPS.cpp, PositionModule, MeshService, and GPSStatus.h with a single-line LOG_DEBUG_GPS() call (src/gps/GPSLog.h, modeled on LOG_MIGRATION: value-gated, ((void)0) when off). Blocks containing declarations, control flow, hexDump, or nested conditionals keep an explicit '#if GPS_DEBUG' guard. RTC.cpp's per-reading raw time dumps and per-candidate rejection chatter fold under the same gate; quality transitions and boot-time seeding stay at debug. Also fixes the '// define GPS_DEBUG' missing-# typo in two variant headers and updates all seven commented examples to the value form ('#define GPS_DEBUG 1') required by the value-based gate. Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1 Co-authored-by: Claude <noreply@anthropic.com> * gps: declare RTC gmtime result as pointer to const (cppcheck) With the setTime debug dump gated behind GPS_DEBUG, all remaining uses of t are reads; cppcheck (constVariablePointer) now flags it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1 --------- Co-authored-by: Claude <noreply@anthropic.com>
Third installment of the logging work (#11374 → #11391 → this). Based on #11391's branch since both touch GPS.cpp; retarget to
developafter #11391 merges.What: replaces the 27 log-only
#ifdef GPS_DEBUG/ log /#endiftriples acrossGPS.cpp,PositionModule.cpp,MeshService.cpp, andGPSStatus.hwith single-lineLOG_DEBUG_GPS(...)calls. The macro lives in newsrc/gps/GPSLog.h, modeled onLOG_MIGRATION: value-gated (#ifndefdefault 0,#if GPS_DEBUGtest, so-DGPS_DEBUG=0explicitly disables),((void)0)off-branch (safe in bracelessif/else). When the gate is off the macro's arguments vanish at preprocessing, so call sites referencing gated-only variables (thedebugmsgprobe dumps) still compile.Deliberately NOT converted (kept as explicit
#if GPS_DEBUGblocks, flipped from#ifdefto value tests): thedebugmsg/responseaccumulation declarations, blocks wrapping control flow, the block that also callsDEBUG_PORT.hexDump, the gate that spans anelse ifclause, theAGE:log with preprocessor conditionals nested in its argument list, and the inverted#ifndef GPS_DEBUGchecksum-threshold gate (behavioral, not verbosity). The handful of gatedLOG_INFO/LOG_WARNdiagnostics unify to the single DEBUG-level macro — they're opt-in diagnostics, so the level tag is incidental.Also:
src/gps/RTC.cpp's per-reading raw time dumps (RV3028/RX8130CE get/set) and per-candidate rejection chatter fold under the same gate (−432 B on rak4631, measured); RTC-quality transitions and boot-time seeding stay at DEBUG.// define GPS_DEBUGmissing-#typo in two variant headers (uncommenting them silently did nothing) and updates all seven commented examples to the value form#define GPS_DEBUG 1..github/copilot-instructions.md:LOG_TRACE= per-packet firehose (globally gated),LOG_DEBUG_<SUBSYS>= subsystem bring-up detail (per-subsystem gate), anomalies stay unconditional.Other subsystems (sensors, radio interfaces, input, PhoneAPI) could get the same treatment later — deliberately out of scope here.
🤝 Attestations
Tested via native (portduino): full compile green and
./bin/run-tests.shGREEN 47/47 suites, all CLEAN. rak4631 compiles in both gate states — default (GPS_DEBUG=0, 768,188 B vs 768,620 B base) and-DGPS_DEBUG=1(exercises every converted call site, including the gated-variable consumers). Behavior surface is log output only; no runtime logic touched.🤖 Generated with Claude Code
https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1
Generated by Claude Code
Summary by CodeRabbit
New Features
Improvements