Alex2ESP/src
David 46a27c26e9 AlexaLog: compile in projects that define DEBUG, ERROR or INFO as macros
8ea7778 introduced AlexaLogLevel::NONE, ERROR, INFO and DEBUG. A sketch that starts with "#define DEBUG 1", or a project built with -DDEBUG, did not compile any more: "expected identifier before numeric constant" at the enumerator, and with the build flag also in the library's own files, because ALEX2ESP_LOGD spelled AlexaLogLevel::DEBUG wherever it expanded. The same sketch builds against 1.1.0.

AlexaLog.h declares the enumerators between #pragma push_macro / #undef and #pragma pop_macro of the four names: a macro of the sketch is set aside for the declaration and is back after it. ALEX2ESP_LOG takes the level as its number and casts it, so no call site names an enumerator. AlexaLog.cpp, the one file that names the levels, undefines the four names after its includes.

For a sketch: nothing changes unless it defines such a macro. One that does cannot write AlexaLogLevel::DEBUG, because the preprocessor replaces the name; setLogLevel(static_cast<AlexaLogLevel>(3)) selects the same level. NONE is set aside in AlexaLog.h as well, but a project that defines NONE fails for another reason: AsyncMqttClient has an enumerator NONE (ParsingInformation.hpp).

Built for d1_mini with empty credentials (PlatformIO 6.2.0, espressif8266 4.2.1), examples/basicLight.cpp, static RAM / flash in bytes, 8ea7778 -> this commit, no warnings:
  as committed                                    34,116 / 336,757 -> 34,116 / 336,757
  "#define DEBUG 1" as the first line             does not compile -> 34,116 / 336,757
  DEBUG, ERROR and INFO defined in front          34,116 / 336,757
  build_flags = -DDEBUG                           does not compile (28 errors) -> 34,116 / 336,757
  build_flags = -DDEBUG -DERROR -DINFO            34,116 / 336,757
The other four examples are unchanged as well (34,232 / 340,517, 34,380 / 341,177, 34,024 / 335,457, 34,256 / 338,925).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-28 15:30:46 +00:00
..
Alex2ESP.cpp Drop the HTTP fallback: directives arrive on <root>/<id>/alexaDirective and reports leave over MQTT 2026-09-28 14:31:57 +00:00
Alex2ESP.h Drop the HTTP fallback: directives arrive on <root>/<id>/alexaDirective and reports leave over MQTT 2026-09-28 14:31:57 +00:00
AlexaBridgeLogic.cpp Drop the HTTP fallback: directives arrive on <root>/<id>/alexaDirective and reports leave over MQTT 2026-09-28 14:31:57 +00:00
AlexaBridgeLogic.h Drop the HTTP fallback: directives arrive on <root>/<id>/alexaDirective and reports leave over MQTT 2026-09-28 14:31:57 +00:00
AlexaCompat.h Drop the HTTP fallback: directives arrive on <root>/<id>/alexaDirective and reports leave over MQTT 2026-09-28 14:31:57 +00:00
AlexaDevice.cpp Drop the HTTP fallback: directives arrive on <root>/<id>/alexaDirective and reports leave over MQTT 2026-09-28 14:31:57 +00:00
AlexaDevice.h Drop the HTTP fallback: directives arrive on <root>/<id>/alexaDirective and reports leave over MQTT 2026-09-28 14:31:57 +00:00
AlexaInterface.h Drop the HTTP fallback: directives arrive on <root>/<id>/alexaDirective and reports leave over MQTT 2026-09-28 14:31:57 +00:00
AlexaLog.cpp AlexaLog: compile in projects that define DEBUG, ERROR or INFO as macros 2026-09-28 15:30:46 +00:00
AlexaLog.h AlexaLog: compile in projects that define DEBUG, ERROR or INFO as macros 2026-09-28 15:30:46 +00:00
AlexaStatusMessage.cpp Drop the HTTP fallback: directives arrive on <root>/<id>/alexaDirective and reports leave over MQTT 2026-09-28 14:31:57 +00:00
AlexaStatusMessage.h Drop the HTTP fallback: directives arrive on <root>/<id>/alexaDirective and reports leave over MQTT 2026-09-28 14:31:57 +00:00
AlexaTransport.h Drop the HTTP fallback: directives arrive on <root>/<id>/alexaDirective and reports leave over MQTT 2026-09-28 14:31:57 +00:00
AlexaUtils.h Drop the HTTP fallback: directives arrive on <root>/<id>/alexaDirective and reports leave over MQTT 2026-09-28 14:31:57 +00:00