Skip to content

Commit

Permalink
Ensure we log the full generated setup payload in chip-tool. (#21207)
Browse files Browse the repository at this point in the history
For large payloads we were only logging whatever happened to fit in
CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Nov 1, 2023
1 parent f10975d commit 1303571
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ CHIP_ERROR SetupPayloadGenerateQRCodeCommand::Run()

std::string code;
ReturnErrorOnFailure(generator.payloadBase38RepresentationWithAutoTLVBuffer(code));
// CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE includes various prefixes we don't
// control (timestamps, process ids, etc). Let's assume (hope?) that
// those prefixes use up no more than half the total available space.
constexpr size_t chunkSize = CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE / 2;
while (code.size() > chunkSize)
{
ChipLogProgress(chipTool, "QR Code: %s", code.substr(0, chunkSize).c_str());
code = code.substr(chunkSize);
}
ChipLogProgress(chipTool, "QR Code: %s", code.c_str());

return CHIP_NO_ERROR;
Expand Down

0 comments on commit 1303571

Please sign in to comment.