Repository navigation
Conversation
…2773 item 2.3) Adds the verbosity tier described in the #2773 binary-size tracker. The default (level 1) preserves the current `FL_WARN` / `FL_INFO` / `FL_ERROR` / `FL_PRINT` behavior — full sstream-based formatting with the file + line + severity prefix. Setting `FASTLED_LOG_VERBOSITY=0` turns each of those macros into a type-checked no-op (`do { if (false) { (void)(fl::sstream_noop() << X); } } while (0)`), so: - The merged `.str1.1` rodata pool that previously held every call site's `__FILE__` + `__LINE__` + " WARN: " + user-message literal goes away — the optimizer drops the `if (false)` branch before `--gc-sections` ever sees the literal references. - User stream expressions stay type-checked, so a future build that flips back to level 1 doesn't surface fresh compile errors. - Side-effects in `FL_WARN("…" << ++counter)` are *not* preserved — consistent with the documented contract of logging macros across the Arduino ecosystem (callers should keep diagnostics pure). - `FASTLED_NO_LOG=1` is honored: it forces `FASTLED_LOG_VERBOSITY=0` so existing opt-out scripts keep working with the new gate. ## Empirical savings on ESP32-S3 Blink (PlatformIO + IDF 5.4) | Build flags | `firmware.bin` | |---|---:| | master baseline (verbosity defaults to 1) | 654,192 B | | `-DFASTLED_LOG_VERBOSITY=0` | **620,384 B** | Net: **–33,808 B (–33 KB, –5.2 %)**. Matches the meta-tracker's 20–40 KB projection. The win is real-binary, not theoretical, because every `FL_WARN`/`FL_INFO`/`FL_ERROR`/`FL_PRINT` call site bakes its strings into the sketch translation unit; collapsing them all is the only way to shrink the merged string pool that #2773 measured at ~58 KB on a stock Blink. ## Tests - [x] `bash test fastled_core --cpp --clean` — 1/1 passes at default verbosity (level 1, current behavior) - [x] `bash compile esp32s3 --examples Blink --platformio` at default → matches master byte-for-byte (no regression) - [x] `bash compile esp32s3 --examples Blink --platformio --defines FASTLED_LOG_VERBOSITY=0` → 620,384 B (the 33 KB drop above) Refs: #2773 #2473 Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
📝 WalkthroughWalkthroughThis PR introduces ChangesLogging Verbosity Gating
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/fl/log/log.h`:
- Around line 54-61: Replace the Unicode em-dash characters (U+2014) used in the
level descriptions comments (the lines starting with "0 — Release", "1 —
Default", and "2 — Verbose" in src/fl/log/log.h) with ASCII hyphens (-); ensure
the comments now read "0 - Release", "1 - Default", "2 - Verbose" and save the
file with 7-bit ASCII encoding so the header complies with the project's C++
source ASCII-only rule.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 63bfd51e-03b0-48e0-9843-f207188601e8
📒 Files selected for processing (1)
src/fl/log/log.h
| // 0 — Release: FL_WARN/FL_INFO/FL_ERROR/FL_PRINT expand to type-checked | ||
| // no-ops (`if (false) sstream_noop() << X`). Format strings and | ||
| // sstream operator chains disappear; the linker garbage-collects the | ||
| // merged string pool. Best for shipping firmware where Serial isn't | ||
| // used at runtime. | ||
| // 1 — Default (current behavior): full stream formatting on platforms | ||
| // where SKETCH_HAS_LARGE_MEMORY allows it. | ||
| // 2 — Verbose: reserved for future use; currently behaves like 1. |
There was a problem hiding this comment.
Replace Unicode em-dashes with ASCII hyphens.
Lines 54, 59, and 61 use Unicode em-dash characters (U+2014 "—") in the level descriptions, violating the strict 7-bit ASCII requirement for C++ source files.
As per coding guidelines, all source code in .h/.cpp/.hpp files must be strictly 7-bit ASCII (no emoji or Unicode punctuation in comments/strings).
🔧 Proposed fix
-// 0 — Release: FL_WARN/FL_INFO/FL_ERROR/FL_PRINT expand to type-checked
+// 0 - Release: FL_WARN/FL_INFO/FL_ERROR/FL_PRINT expand to type-checked
// no-ops (`if (false) sstream_noop() << X`). Format strings and
// sstream operator chains disappear; the linker garbage-collects the
// merged string pool. Best for shipping firmware where Serial isn't
// used at runtime.
-// 1 — Default (current behavior): full stream formatting on platforms
+// 1 - Default (current behavior): full stream formatting on platforms
// where SKETCH_HAS_LARGE_MEMORY allows it.
-// 2 — Verbose: reserved for future use; currently behaves like 1.
+// 2 - Verbose: reserved for future use; currently behaves like 1.Based on coding guidelines: "Keep all source code strictly 7-bit ASCII in .h/.cpp/.hpp files (no emoji or Unicode punctuation in comments/strings)" (agents/docs/cpp-standards.md).
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // 0 — Release: FL_WARN/FL_INFO/FL_ERROR/FL_PRINT expand to type-checked | |
| // no-ops (`if (false) sstream_noop() << X`). Format strings and | |
| // sstream operator chains disappear; the linker garbage-collects the | |
| // merged string pool. Best for shipping firmware where Serial isn't | |
| // used at runtime. | |
| // 1 — Default (current behavior): full stream formatting on platforms | |
| // where SKETCH_HAS_LARGE_MEMORY allows it. | |
| // 2 — Verbose: reserved for future use; currently behaves like 1. | |
| // 0 - Release: FL_WARN/FL_INFO/FL_ERROR/FL_PRINT expand to type-checked | |
| // no-ops (`if (false) sstream_noop() << X`). Format strings and | |
| // sstream operator chains disappear; the linker garbage-collects the | |
| // merged string pool. Best for shipping firmware where Serial isn't | |
| // used at runtime. | |
| // 1 - Default (current behavior): full stream formatting on platforms | |
| // where SKETCH_HAS_LARGE_MEMORY allows it. | |
| // 2 - Verbose: reserved for future use; currently behaves like 1. |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/fl/log/log.h` around lines 54 - 61, Replace the Unicode em-dash
characters (U+2014) used in the level descriptions comments (the lines starting
with "0 — Release", "1 — Default", and "2 — Verbose" in src/fl/log/log.h) with
ASCII hyphens (-); ensure the comments now read "0 - Release", "1 - Default", "2
- Verbose" and save the file with 7-bit ASCII encoding so the header complies
with the project's C++ source ASCII-only rule.
|
Closing in favor of #2791, which is strictly better:
The only thing this PR has that #2791 doesn't is the No reason to land two competing implementations. |
Implements item 2.3 from the ESP32-S3 binary-size meta tracker (#2773) — the projected single biggest remaining lever, validated on stock Blink at the projected savings range.
What this adds
A three-level
FASTLED_LOG_VERBOSITYknob gatingFL_WARN/FL_INFO/FL_ERROR/FL_PRINT(and their_IF/_ONCE/_EVERY/_FMTsiblings):=1(default, no change vs master) — full stream formatting on platforms whereSKETCH_HAS_LARGE_MEMORYallows it=0— each macro expands todo { if (false) { (void)(fl::sstream_noop() << X); } } while (0). User stream expressions stay type-checked but the format strings dead-strip=2— reserved for future use; currently behaves like=1FASTLED_NO_LOG=1is honored: it forces level 0 so existing opt-out scripts keep working with the new gate.Why this works
#2773's analysis pinpointed
.str1.1(the merged rodata pool of everyFL_WARN/FL_LOGformat string baked into the sketch translation unit) as ~58 KB — by far the single biggest rodata contributor on stock Blink. Withif (false)guarding the sstream chain, the optimizer drops the whole branch before--gc-sectionsever sees the literal references — including the__FILE__+__LINE__+WARN:+ user-message tokens at every call site.Empirical savings (ESP32-S3 Blink, PlatformIO + IDF 5.4)
firmware.bin-DFASTLED_LOG_VERBOSITY=0Net: –33,808 B (–33 KB, –5.2 %). Right in the meta tracker's 20–40 KB projection range.
What does NOT change
FASTLED_LOG_VERBOSITYunset → level 1 → byte-for-byte identical to current master. Users who haven't opted in see no change in either behavior or binary size.FL_WARN("…" << ++counter)is not preserved at level 0, consistent with the documented contract of logging macros across the Arduino ecosystem (logging shouldn't have side effects). At level 1 the existing behavior is unchanged.FL_DBG, theFASTLED_LOG_*_ENABLEDasync loggers, and theFASTLED_DBG/FASTLED_WARN/FASTLED_INFO/FASTLED_ERRORupper-case variants are NOT gated by this knob (separate concerns / separate users).Tests
bash test fastled_core --cpp --clean— 1/1 passes at default verbositybash compile esp32s3 --examples Blink --platformioat default → matches master byte-for-bytebash compile esp32s3 --examples Blink --platformio --defines FASTLED_LOG_VERBOSITY=0→ 620,384 B (the 33 KB drop above)Cumulative Batch 1 + 2.3 picture
Stacking against the meta tracker:
firmware.binRefs: #2773 #2473
🤖 Generated with Claude Code
Summary by CodeRabbit