[log] Add ESPHOME_DEBUG_ASSERT for log function invariants

Add ESPHOME_DEBUG_ASSERT macro that only fires when ESPHOME_DEBUG is
defined. Use it to assert global_logger is not null in log functions.
Enable ESPHOME_DEBUG in C++ unit test builds so these assertions are
active during testing but have zero cost in production firmware.
This commit is contained in:
J. Nick Koston
2026-03-05 22:05:17 -10:00
parent d8600b5bc9
commit 6e36af6c4b
3 changed files with 13 additions and 0 deletions
+1
View File
@@ -100,6 +100,7 @@ def create_test_config(config_name: str, includes: list[str]) -> dict:
"build_flags": [
"-Og", # optimize for debug
"-DUSE_TIME_TIMEZONE", # enable timezone code paths for testing
"-DESPHOME_DEBUG", # enable debug assertions
],
"debug_build_flags": [ # only for debug builds
"-g3", # max debug info