Skip to content

Commit

Permalink
Stop logging "Error:" in chip-tool-darwin when there is no error. (#1…
Browse files Browse the repository at this point in the history
…8101)

Running something like:

  chip-tool-darwin operationalcredentials read fabrics NODE_ID 0

ends up logging:

  [1651763766864] [75364:41306780] CHIP: [TOO] OperationalCredentials Fabrics Error: ../../../examples/chip-tool-darwin/third_party/connectedhomeip/src/darwin/Framework/CHIP/CHIPError.mm:214: Success

as an error-level log, which is pretty confusing.  This change skips
logging the "Error: ..." bits if there is in fact no error.
  • Loading branch information
bzbarsky-apple authored May 5, 2022
1 parent 55ac529 commit fe4798b
Show file tree
Hide file tree
Showing 2 changed files with 3,782 additions and 1,463 deletions.
12 changes: 9 additions & 3 deletions examples/chip-tool-darwin/templates/commands.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public:
^(NSError * _Nullable error) {
{{/if}}
chipError = [CHIPError errorToCHIPErrorCode:error];
ChipLogProgress(chipTool, "Error: %s", chip::ErrorStr(chipError));
if (error != nil) {
ChipLogProgress(chipTool, "Error: %s", chip::ErrorStr(chipError));
}
SetCommandExitStatus(chipError);
}];
return chipError;
Expand Down Expand Up @@ -133,7 +135,9 @@ public:
NSLog(@"{{asUpperCamelCase parent.name}}.{{asUpperCamelCase name}} response %@", [value description]);
err = [CHIPError errorToCHIPErrorCode:error];

ChipLogError(chipTool, "{{asUpperCamelCase parent.name}} {{asUpperCamelCase name}} Error: %s", chip::ErrorStr(err));
if (error != nil) {
ChipLogError(chipTool, "{{asUpperCamelCase parent.name}} {{asUpperCamelCase name}} read Error: %s", chip::ErrorStr(err));
}
SetCommandExitStatus(err);
}];
return err;
Expand Down Expand Up @@ -188,7 +192,9 @@ public:

[cluster writeAttribute{{asUpperCamelCase name}}WithValue:value params:params completionHandler:^(NSError * _Nullable error) {
chipError = [CHIPError errorToCHIPErrorCode:error];
ChipLogError(chipTool, "{{asUpperCamelCase parent.name}} {{asUpperCamelCase name}} Error: %s", chip::ErrorStr(chipError));
if (error != nil) {
ChipLogError(chipTool, "{{asUpperCamelCase parent.name}} {{asUpperCamelCase name}} write Error: %s", chip::ErrorStr(chipError));
}
SetCommandExitStatus(chipError);
}];
return chipError;
Expand Down
Loading

0 comments on commit fe4798b

Please sign in to comment.