Skip to content

Commit a93dba5

Browse files
Improve MTRDevice work item logging. (project-chip#32936)
Stop including the node ID in the description passed to enqueueWorkItem, because the work queue includes that already. Use hex for node IDs, cluster IDs, command/attribute IDs (but keep using decimal for endpoint IDs), to be consistent with other logging.
1 parent b6c47f6 commit a93dba5

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/darwin/Framework/CHIP/MTRDevice.mm

+11-11
Original file line numberDiff line numberDiff line change
@@ -1522,23 +1522,23 @@ static BOOL AttributeHasChangesOmittedQuality(MTRAttributePath * attributePath)
15221522
while (readRequestsNext.count) {
15231523
// Can only read up to 9 paths at a time, per spec
15241524
if (readRequestsCurrent.count >= 9) {
1525-
MTR_LOG_INFO("Batching read attribute work item [%llu]: cannot add more work, item is full [%@:%@:%@:%@]", workItemID, nodeID, endpointID, clusterID, attributeID);
1525+
MTR_LOG_INFO("Batching read attribute work item [%llu]: cannot add more work, item is full [0x%016llX:%@:0x%llx:0x%llx]", workItemID, nodeID.unsignedLongLongValue, endpointID, clusterID.unsignedLongLongValue, attributeID.unsignedLongLongValue);
15261526
return outcome;
15271527
}
15281528

15291529
// if params don't match then they cannot be merged
15301530
if (![readRequestsNext[0][MTRDeviceReadRequestFieldParamsIndex]
15311531
isEqual:readRequestsCurrent[0][MTRDeviceReadRequestFieldParamsIndex]]) {
1532-
MTR_LOG_INFO("Batching read attribute work item [%llu]: cannot add more work, parameter mismatch [%@:%@:%@:%@]", workItemID, nodeID, endpointID, clusterID, attributeID);
1532+
MTR_LOG_INFO("Batching read attribute work item [%llu]: cannot add more work, parameter mismatch [0x%016llX:%@:0x%llx:0x%llx]", workItemID, nodeID.unsignedLongLongValue, endpointID, clusterID.unsignedLongLongValue, attributeID.unsignedLongLongValue);
15331533
return outcome;
15341534
}
15351535

15361536
// merge the next item's first request into the current item's list
15371537
auto readItem = readRequestsNext.firstObject;
15381538
[readRequestsNext removeObjectAtIndex:0];
15391539
[readRequestsCurrent addObject:readItem];
1540-
MTR_LOG_INFO("Batching read attribute work item [%llu]: added %@ (now %tu requests total) [%@:%@:%@:%@]",
1541-
workItemID, readItem, readRequestsCurrent.count, nodeID, endpointID, clusterID, attributeID);
1540+
MTR_LOG_INFO("Batching read attribute work item [%llu]: added %@ (now %tu requests total) [0x%016llX:%@:0x%llx:0x%llx]",
1541+
workItemID, readItem, readRequestsCurrent.count, nodeID.unsignedLongLongValue, endpointID, clusterID.unsignedLongLongValue, attributeID.unsignedLongLongValue);
15421542
outcome = MTRBatchedPartially;
15431543
}
15441544
NSCAssert(readRequestsNext.count == 0, @"should have batched everything or returned early");
@@ -1548,7 +1548,7 @@ static BOOL AttributeHasChangesOmittedQuality(MTRAttributePath * attributePath)
15481548
mtr_hide(self); // don't capture self accidentally
15491549
for (NSArray * readItem in readRequests) {
15501550
if ([readItem isEqual:opaqueItemData]) {
1551-
MTR_LOG_DEFAULT("Read attribute work item [%llu] report duplicate %@ [%@:%@:%@:%@]", workItemID, readItem, nodeID, endpointID, clusterID, attributeID);
1551+
MTR_LOG_DEFAULT("Read attribute work item [%llu] report duplicate %@ [0x%016llX:%@:0x%llx:0x%llx]", workItemID, readItem, nodeID.unsignedLongLongValue, endpointID, clusterID.unsignedLongLongValue, attributeID.unsignedLongLongValue);
15521552
*isDuplicate = YES;
15531553
*stop = YES;
15541554
return;
@@ -1585,23 +1585,23 @@ static BOOL AttributeHasChangesOmittedQuality(MTRAttributePath * attributePath)
15851585
if (values) {
15861586
// Since the format is the same data-value dictionary, this looks like an
15871587
// attribute report
1588-
MTR_LOG_INFO("Read attribute work item [%llu] result: %@ [%@:%@:%@:%@]", workItemID, values, nodeID, endpointID, clusterID, attributeID);
1588+
MTR_LOG_INFO("Read attribute work item [%llu] result: %@ [0x%016llX:%@:0x%llX:0x%llX]", workItemID, values, nodeID.unsignedLongLongValue, endpointID, clusterID.unsignedLongLongValue, attributeID.unsignedLongLongValue);
15891589
[self _handleAttributeReport:values];
15901590
}
15911591

15921592
// TODO: better retry logic
15931593
if (error && (retryCount < 2)) {
1594-
MTR_LOG_ERROR("Read attribute work item [%llu] failed (will retry): %@ [%@:%@:%@:%@]", workItemID, error, nodeID, endpointID, clusterID, attributeID);
1594+
MTR_LOG_ERROR("Read attribute work item [%llu] failed (will retry): %@ [0x%016llX:%@:0x%llx:0x%llx]", workItemID, error, nodeID.unsignedLongLongValue, endpointID, clusterID.unsignedLongLongValue, attributeID.unsignedLongLongValue);
15951595
completion(MTRAsyncWorkNeedsRetry);
15961596
} else {
15971597
if (error) {
1598-
MTR_LOG_DEFAULT("Read attribute work item [%llu] failed (giving up): %@ [%@:%@:%@:%@]", workItemID, error, nodeID, endpointID, clusterID, attributeID);
1598+
MTR_LOG_DEFAULT("Read attribute work item [%llu] failed (giving up): %@ [0x%016llX:%@:0x%llx:0x%llx]", workItemID, error, nodeID.unsignedLongLongValue, endpointID, clusterID.unsignedLongLongValue, attributeID.unsignedLongLongValue);
15991599
}
16001600
completion(MTRAsyncWorkComplete);
16011601
}
16021602
}];
16031603
}];
1604-
[_asyncWorkQueue enqueueWorkItem:workItem descriptionWithFormat:@"read %@ %@ %@ %@", self.nodeID, endpointID, clusterID, attributeID];
1604+
[_asyncWorkQueue enqueueWorkItem:workItem descriptionWithFormat:@"read %@ 0x%llx 0x%llx", endpointID, clusterID.unsignedLongLongValue, attributeID.unsignedLongLongValue];
16051605
}
16061606

16071607
return attributeValueToReturn;
@@ -1669,7 +1669,7 @@ - (void)writeAttributeWithEndpointID:(NSNumber *)endpointID
16691669
completion(MTRAsyncWorkComplete);
16701670
}];
16711671
}];
1672-
[_asyncWorkQueue enqueueWorkItem:workItem descriptionWithFormat:@"write %@ %@ %@ %@", self.nodeID, endpointID, clusterID, attributeID];
1672+
[_asyncWorkQueue enqueueWorkItem:workItem descriptionWithFormat:@"write %@ 0x%llx 0x%llx", endpointID, clusterID.unsignedLongLongValue, attributeID.unsignedLongLongValue];
16731673
}
16741674

16751675
- (void)invokeCommandWithEndpointID:(NSNumber *)endpointID
@@ -1819,7 +1819,7 @@ - (void)_invokeCommandWithEndpointID:(NSNumber *)endpointID
18191819
workDone(values, error);
18201820
}];
18211821
}];
1822-
[_asyncWorkQueue enqueueWorkItem:workItem descriptionWithFormat:@"invoke %@ %@ %@", endpointID, clusterID, commandID];
1822+
[_asyncWorkQueue enqueueWorkItem:workItem descriptionWithFormat:@"invoke %@ 0x%llx 0x%llx", endpointID, clusterID.unsignedLongLongValue, commandID.unsignedLongLongValue];
18231823
}
18241824

18251825
- (void)_invokeKnownCommandWithEndpointID:(NSNumber *)endpointID

0 commit comments

Comments
 (0)