Keep the root topic out of the log: print endpoint ids and topics without their root
The root topic identifies the account, and Serial logs get posted in issues and forums. "repeated directive on <topic> ignored" and the lines for dropped directives printed the full MQTT topic; they now start with the endpoint id. The lines for subscriptions and publishes print the topic relative to the root (AlexaBridgeLogic::topicForLog), and begin() prints the length of the root topic instead of its text. No line at any level prints the root topic, the username or the password. basicLight: RAM 34,476 -> 34,508 B, flash 338,281 -> 338,533 B; host tests 45 -> 47. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
2ed52c8721
commit
d534f23f27
7 changed files with 79 additions and 25 deletions
|
|
@ -753,6 +753,30 @@ void test_other_topics_are_not_directive_topics()
|
|||
TEST_ASSERT_NULL(AlexaBridgeLogic::directiveEndpoint("root/ESP-01/alexaDirective", "root", nullptr));
|
||||
}
|
||||
|
||||
void test_log_prints_a_topic_without_its_root()
|
||||
{
|
||||
TEST_ASSERT_EQUAL_STRING("ESP-01/alexaResponce", AlexaBridgeLogic::topicForLog("root/ESP-01/alexaResponce", "root"));
|
||||
TEST_ASSERT_EQUAL_STRING("discover", AlexaBridgeLogic::topicForLog("root/discover", "root"));
|
||||
TEST_ASSERT_EQUAL_STRING("+/alexaDirective", AlexaBridgeLogic::topicForLog("a/b/+/alexaDirective", "a/b"));
|
||||
// An empty root topic (begin() with "") still has the separator
|
||||
TEST_ASSERT_EQUAL_STRING("ESP-01/alexaResponce", AlexaBridgeLogic::topicForLog("/ESP-01/alexaResponce", ""));
|
||||
}
|
||||
|
||||
void test_log_never_prints_the_root_topic()
|
||||
{
|
||||
const char *topics[] = {"root", "root/", "rootless/ESP-01/alexaResponce", "other/root/discover", "", nullptr};
|
||||
|
||||
for (const char *topic : topics)
|
||||
{
|
||||
const char *printed = AlexaBridgeLogic::topicForLog(topic, "root");
|
||||
TEST_ASSERT_NOT_NULL(printed);
|
||||
TEST_ASSERT_NULL(strstr(printed, "root/"));
|
||||
TEST_ASSERT_NULL(strstr(printed, "rootless"));
|
||||
}
|
||||
TEST_ASSERT_EQUAL_STRING("", AlexaBridgeLogic::topicForLog("root/", "root"));
|
||||
TEST_ASSERT_NOT_NULL(AlexaBridgeLogic::topicForLog("root/discover", nullptr));
|
||||
}
|
||||
|
||||
// --- reconnect ---
|
||||
|
||||
void test_wait_doubles_from_a_second_to_a_minute()
|
||||
|
|
@ -900,6 +924,8 @@ int main(int, char **)
|
|||
|
||||
RUN_TEST(test_endpoint_is_taken_from_the_directive_topic);
|
||||
RUN_TEST(test_other_topics_are_not_directive_topics);
|
||||
RUN_TEST(test_log_prints_a_topic_without_its_root);
|
||||
RUN_TEST(test_log_never_prints_the_root_topic);
|
||||
|
||||
RUN_TEST(test_wait_doubles_from_a_second_to_a_minute);
|
||||
RUN_TEST(test_open_session_starts_the_wait_over);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue