Skip to content

Commit

Permalink
Fixed / clarified logging for nodeID, endpoint, cluster, attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
jtung-apple committed Mar 13, 2024
1 parent fb399d4 commit 1191da7
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions src/darwin/Framework/CHIP/MTRDeviceControllerDataStore.mm
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ - (BOOL)_deleteAttributeValueForNodeID:(NSNumber *)nodeID endpointID:(NSNumber *
[self clearStoredAttributesForNodeID:nodeID];
}

MTR_LOG_INFO("Fetch got no value for endpointIndex @ %llu", nodeID.unsignedLongLongValue);
MTR_LOG_INFO("Fetch got no value for endpointIndex @ node 0x%016llX", nodeID.unsignedLongLongValue);
attributesToReturn = nil;
return;
}
Expand All @@ -476,30 +476,30 @@ - (BOOL)_deleteAttributeValueForNodeID:(NSNumber *)nodeID endpointID:(NSNumber *
NSArray<NSNumber *> * endpointIndex = [self _fetchEndpointIndexForNodeID:nodeID];

#if ATTRIBUTE_CACHE_VERBOSE_LOGGING
MTR_LOG_INFO("Fetch got %lu values for endpointIndex @ %llu", static_cast<unsigned long>(endpointIndex.count), nodeID.unsignedLongLongValue);
MTR_LOG_INFO("Fetch got %lu values for endpointIndex @ node 0x%016llX", static_cast<unsigned long>(endpointIndex.count), nodeID.unsignedLongLongValue);
#endif

for (NSNumber * endpointID in endpointIndex) {
// Fetch endpoint index
NSArray<NSNumber *> * clusterIndex = [self _fetchClusterIndexForNodeID:nodeID endpointID:endpointID];

#if ATTRIBUTE_CACHE_VERBOSE_LOGGING
MTR_LOG_INFO("Fetch got %lu values for clusterIndex @ %llu:0x%04X", static_cast<unsigned long>(clusterIndex.count), nodeID.unsignedLongLongValue, endpointID.unsignedShortValue);
MTR_LOG_INFO("Fetch got %lu values for clusterIndex @ node 0x%016llX %u", static_cast<unsigned long>(clusterIndex.count), nodeID.unsignedLongLongValue, endpointID.unsignedShortValue);
#endif

for (NSNumber * clusterID in clusterIndex) {
// Fetch endpoint index
NSArray<NSNumber *> * attributeIndex = [self _fetchAttributeIndexForNodeID:nodeID endpointID:endpointID clusterID:clusterID];

#if ATTRIBUTE_CACHE_VERBOSE_LOGGING
MTR_LOG_INFO("Fetch got %lu values for attributeIndex @ %llu:0x%04X:0x%08lX", static_cast<unsigned long>(attributeIndex.count), nodeID.unsignedLongLongValue, endpointID.unsignedShortValue, clusterID.unsignedLongValue);
MTR_LOG_INFO("Fetch got %lu values for attributeIndex @ node 0x%016llX endpoint %u cluster 0x%08lX", static_cast<unsigned long>(attributeIndex.count), nodeID.unsignedLongLongValue, endpointID.unsignedShortValue, clusterID.unsignedLongValue);
#endif

for (NSNumber * attributeID in attributeIndex) {
NSDictionary * value = [self _fetchAttributeValueForNodeID:nodeID endpointID:endpointID clusterID:clusterID attributeID:attributeID];

#if ATTRIBUTE_CACHE_VERBOSE_LOGGING
MTR_LOG_INFO("Fetch got %u values for attribute value @ %llu:0x%04X:0x%08lX:0x%08lX", value ? 1 : 0, nodeID.unsignedLongLongValue, endpointID.unsignedShortValue, clusterID.unsignedLongValue, attributeID.unsignedLongValue);
MTR_LOG_INFO("Fetch got %u values for attribute value @ node 0x%016llX endpoint %u cluster 0x%08lX attribute 0x%08lX", value ? 1 : 0, nodeID.unsignedLongLongValue, endpointID.unsignedShortValue, clusterID.unsignedLongValue, attributeID.unsignedLongValue);
#endif

if (value) {
Expand Down Expand Up @@ -538,22 +538,22 @@ - (void)_pruneEmptyStoredAttributesBranches

// Fetch node index
NSArray<NSNumber *> * nodeIndex = [self _fetchNodeIndex];
NSMutableArray<NSNumber *> * nodeIndexCopy = nodeIndex.mutableCopy;
NSMutableArray<NSNumber *> * nodeIndexCopy = [nodeIndex mutableCopy];

for (NSNumber * nodeID in nodeIndex) {
// Fetch endpoint index
NSArray<NSNumber *> * endpointIndex = [self _fetchEndpointIndexForNodeID:nodeID];
NSMutableArray<NSNumber *> * endpointIndexCopy = endpointIndex.mutableCopy;
NSMutableArray<NSNumber *> * endpointIndexCopy = [endpointIndex mutableCopy];

for (NSNumber * endpointID in endpointIndex) {
// Fetch endpoint index
NSArray<NSNumber *> * clusterIndex = [self _fetchClusterIndexForNodeID:nodeID endpointID:endpointID];
NSMutableArray<NSNumber *> * clusterIndexCopy = clusterIndex.mutableCopy;
NSMutableArray<NSNumber *> * clusterIndexCopy = [clusterIndex mutableCopy];

for (NSNumber * clusterID in clusterIndex) {
// Fetch endpoint index
NSArray<NSNumber *> * attributeIndex = [self _fetchAttributeIndexForNodeID:nodeID endpointID:endpointID clusterID:clusterID];
NSMutableArray<NSNumber *> * attributeIndexCopy = attributeIndex.mutableCopy;
NSMutableArray<NSNumber *> * attributeIndexCopy = [attributeIndex mutableCopy];

for (NSNumber * attributeID in attributeIndex) {
NSDictionary * value = [self _fetchAttributeValueForNodeID:nodeID endpointID:endpointID clusterID:clusterID attributeID:attributeID];
Expand All @@ -571,8 +571,10 @@ - (void)_pruneEmptyStoredAttributesBranches
[clusterIndexCopy removeObject:clusterID];
success = [self _deleteAttributeIndexForNodeID:nodeID endpointID:endpointID clusterID:clusterID];
}
storeFailures++;
MTR_LOG_INFO("Store failed in _pruneEmptyStoredAttributesBranches for attributeIndex (%lu) @ %llu:0x%04X:0x%08lX", static_cast<unsigned long>(attributeIndexCopy.count), nodeID.unsignedLongLongValue, endpointID.unsignedShortValue, clusterID.unsignedLongValue);
if (!success) {
storeFailures++;
MTR_LOG_INFO("Store failed in _pruneEmptyStoredAttributesBranches for attributeIndex (%lu) @ node 0x%016llX endpoint %u cluster 0x%08lX", static_cast<unsigned long>(attributeIndexCopy.count), nodeID.unsignedLongLongValue, endpointID.unsignedShortValue, clusterID.unsignedLongValue);
}
}
}

Expand All @@ -586,7 +588,7 @@ - (void)_pruneEmptyStoredAttributesBranches
}
if (!success) {
storeFailures++;
MTR_LOG_INFO("Store failed in _pruneEmptyStoredAttributesBranches for clusterIndex (%lu) @ %llu:0x%04X", static_cast<unsigned long>(clusterIndexCopy.count), nodeID.unsignedLongLongValue, endpointID.unsignedShortValue);
MTR_LOG_INFO("Store failed in _pruneEmptyStoredAttributesBranches for clusterIndex (%lu) @ node 0x%016llX endpoint %u", static_cast<unsigned long>(clusterIndexCopy.count), nodeID.unsignedLongLongValue, endpointID.unsignedShortValue);
}
}
}
Expand All @@ -601,7 +603,7 @@ - (void)_pruneEmptyStoredAttributesBranches
}
if (!success) {
storeFailures++;
MTR_LOG_INFO("Store failed in _pruneEmptyStoredAttributesBranches for endpointIndex (%lu) @ %llu", static_cast<unsigned long>(endpointIndexCopy.count), nodeID.unsignedLongLongValue);
MTR_LOG_INFO("Store failed in _pruneEmptyStoredAttributesBranches for endpointIndex (%lu) @ node 0x%016llX", static_cast<unsigned long>(endpointIndexCopy.count), nodeID.unsignedLongLongValue);
}
}
}
Expand Down Expand Up @@ -634,7 +636,7 @@ - (void)storeAttributeValues:(NSArray<NSDictionary *> *)dataValues forNodeID:(NS
NSDictionary * value = dataValue[MTRDataKey];

#if ATTRIBUTE_CACHE_VERBOSE_LOGGING
MTR_LOG_INFO("Attempt to store attribute value @ %llu:0x%04X:0x%08lX:0x%08lX", nodeID.unsignedLongLongValue, path.endpoint.unsignedShortValue, path.cluster.unsignedLongValue, path.attribute.unsignedLongValue);
MTR_LOG_INFO("Attempt to store attribute value @ node 0x%016llX endpoint %u cluster 0x%08lX attribute 0x%08lX", nodeID.unsignedLongLongValue, path.endpoint.unsignedShortValue, path.cluster.unsignedLongValue, path.attribute.unsignedLongValue);
#endif

BOOL storeFailed = NO;
Expand Down Expand Up @@ -662,7 +664,7 @@ - (void)storeAttributeValues:(NSArray<NSDictionary *> *)dataValues forNodeID:(NS
}
if (storeFailed) {
storeFailures++;
MTR_LOG_INFO("Store failed for endpointIndex @ %llu", nodeID.unsignedLongLongValue);
MTR_LOG_INFO("Store failed for endpointIndex @ node 0x%016llX", nodeID.unsignedLongLongValue);
continue;
}

Expand All @@ -676,7 +678,7 @@ - (void)storeAttributeValues:(NSArray<NSDictionary *> *)dataValues forNodeID:(NS
}
if (storeFailed) {
storeFailures++;
MTR_LOG_INFO("Store failed for clusterIndex @ %llu:0x%04X", nodeID.unsignedLongLongValue, path.endpoint.unsignedShortValue);
MTR_LOG_INFO("Store failed for clusterIndex @ node 0x%016llX endpoint %u", nodeID.unsignedLongLongValue, path.endpoint.unsignedShortValue);
continue;
}

Expand All @@ -693,15 +695,15 @@ - (void)storeAttributeValues:(NSArray<NSDictionary *> *)dataValues forNodeID:(NS
}
if (storeFailed) {
storeFailures++;
MTR_LOG_INFO("Store failed for attributeIndex @ %llu:0x%04X:0x%08lX", nodeID.unsignedLongLongValue, path.endpoint.unsignedShortValue, path.cluster.unsignedLongValue);
MTR_LOG_INFO("Store failed for attributeIndex @ node 0x%016llX endpoint %u cluster 0x%08lX", nodeID.unsignedLongLongValue, path.endpoint.unsignedShortValue, path.cluster.unsignedLongValue);
continue;
}

// Store value
storeFailed = ![self _storeAttributeValue:value forNodeID:nodeID endpointID:path.endpoint clusterID:path.cluster attributeID:path.attribute];
if (storeFailed) {
storeFailures++;
MTR_LOG_INFO("Store failed for attribute value @ %llu:0x%04X:0x%08lX:0x%08lX", nodeID.unsignedLongLongValue, path.endpoint.unsignedShortValue, path.cluster.unsignedLongValue, path.attribute.unsignedLongValue);
MTR_LOG_INFO("Store failed for attribute value @ node 0x%016llX endpoint %u cluster 0x%08lX attribute 0x%08lX", nodeID.unsignedLongLongValue, path.endpoint.unsignedShortValue, path.cluster.unsignedLongValue, path.attribute.unsignedLongValue);
}
}

Expand Down Expand Up @@ -739,31 +741,31 @@ - (void)_clearStoredAttributesForNodeID:(NSNumber *)nodeID
for (NSNumber * attributeID in attributeIndex) {
BOOL success = [self _deleteAttributeValueForNodeID:nodeID endpointID:endpointID clusterID:clusterID attributeID:attributeID];
if (!success) {
MTR_LOG_INFO("Delete failed for attribute value @ %llu:0x%04X:0x%08lX:0x%08lX", nodeID.unsignedLongLongValue, endpointID.unsignedShortValue, clusterID.unsignedLongValue, attributeID.unsignedLongValue);
MTR_LOG_INFO("Delete failed for attribute value @ node 0x%016llX endpoint %u cluster 0x%08lX attribute 0x%08lX", nodeID.unsignedLongLongValue, endpointID.unsignedShortValue, clusterID.unsignedLongValue, attributeID.unsignedLongValue);
} else {
attributesCleared++;
}
}

BOOL success = [self _deleteAttributeIndexForNodeID:nodeID endpointID:endpointID clusterID:clusterID];
if (!success) {
MTR_LOG_INFO("Delete failed for attributeIndex @ %llu:0x%04X:0x%08lX", nodeID.unsignedLongLongValue, endpointID.unsignedShortValue, clusterID.unsignedLongValue);
MTR_LOG_INFO("Delete failed for attributeIndex @ node 0x%016llX endpoint %u cluster 0x%08lX", nodeID.unsignedLongLongValue, endpointID.unsignedShortValue, clusterID.unsignedLongValue);
} else {
clustersCleared++;
}
}

BOOL success = [self _deleteClusterIndexForNodeID:nodeID endpointID:endpointID];
if (!success) {
MTR_LOG_INFO("Delete failed for clusterIndex @ %llu:0x%04X", nodeID.unsignedLongLongValue, endpointID.unsignedShortValue);
MTR_LOG_INFO("Delete failed for clusterIndex @ node 0x%016llX endpoint %u", nodeID.unsignedLongLongValue, endpointID.unsignedShortValue);
} else {
endpointsCleared++;
}
}

BOOL success = [self _deleteEndpointIndexForNodeID:nodeID];
if (!success) {
MTR_LOG_INFO("Delete failed for endpointrIndex @ %llu", nodeID.unsignedLongLongValue);
MTR_LOG_INFO("Delete failed for endpointrIndex @ node 0x%016llX", nodeID.unsignedLongLongValue);
}

MTR_LOG_INFO("clearStoredAttributesForNodeID: deleted endpoints %lu/%lu clusters %lu/%lu attributes %lu/%lu", static_cast<unsigned long>(endpointsCleared), static_cast<unsigned long>(endpointsClearAttempts), static_cast<unsigned long>(clustersCleared), static_cast<unsigned long>(clustersClearAttempts), static_cast<unsigned long>(attributesCleared), static_cast<unsigned long>(attributesClearAttempts));
Expand All @@ -774,7 +776,7 @@ - (void)clearStoredAttributesForNodeID:(NSNumber *)nodeID
dispatch_async(_storageDelegateQueue, ^{
[self _clearStoredAttributesForNodeID:nodeID];
NSArray<NSNumber *> * nodeIndex = [self _fetchNodeIndex];
NSMutableArray<NSNumber *> * nodeIndexCopy = nodeIndex.mutableCopy;
NSMutableArray<NSNumber *> * nodeIndexCopy = [nodeIndex mutableCopy];
[nodeIndexCopy removeObject:nodeID];
if (nodeIndex.count != nodeIndexCopy.count) {
BOOL success;
Expand Down

0 comments on commit 1191da7

Please sign in to comment.