Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split JSON log tracing line by line for better alignment #28897

Merged
merged 3 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def __init__(self, log):
base64_message = log["message"].encode('utf-8')
decoded_message_bytes = base64.b64decode(base64_message)
# TODO We do assume utf-8 encoding is used, it may not be true though.
self.message = decoded_message_bytes.decode('utf-8')
self.message = decoded_message_bytes.decode('utf-8', 'replace')

def decode_logs(logs):
return list(map(MatterLog, logs))
Expand Down
8 changes: 4 additions & 4 deletions src/lib/format/protocol_messages.matter
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ client cluster IMProtocol = 0xFFFF0001 {
boolean keep_subscriptions = 0;
int16u min_minterval_floor = 1;
int16u max_minterval_ceiling = 2;
optional AttributePathIB attribute_requests = 3;
optional EventPathIB event_requests = 4;
optional EventFilterIB event_filters = 5;
optional AttributePathIB attribute_requests[] = 3;
optional EventPathIB event_requests[] = 4;
optional EventFilterIB event_filters[] = 5;
// NOTE: 6 is missing here ...
boolean fabric_filtered = 7;
optional DataVersionFilterIB data_version_filters = 8;
optional DataVersionFilterIB data_version_filters[] = 8;

// 10.2.2.2. Context Tag Encoded Action Information
int8u interaction_model_revison = 0xFF;
Expand Down
11 changes: 10 additions & 1 deletion src/tracing/json/json_tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <lib/support/CHIPMem.h>
#include <lib/support/ErrorStr.h>
#include <lib/support/StringBuilder.h>
#include <lib/support/StringSplitter.h>
#include <transport/TracingStructs.h>

#include <log_json/log_json_build_config.h>
Expand Down Expand Up @@ -444,7 +445,15 @@ void JsonBackend::OutputValue(::Json::Value & value)
{
std::stringstream output;
writer->write(value, &output);
ChipLogProgress(Automation, "%s", output.str().c_str());
// For pretty-printing, output each log line individually.
std::string data_string = output.str();
chip::StringSplitter splitter(data_string.c_str(), '\n');

chip::CharSpan line;
while (splitter.Next(line))
{
ChipLogProgress(Automation, "%.*s", static_cast<int>(line.size()), line.data());
}
}
}

Expand Down