Skip to content

Commit ea4fc7c

Browse files
Add some more progress-style logging to Darwin server endpoints. (#32047)
Lets us track when endpoints/clusters/attributes are set up and attribute values changed.
1 parent ec9cdbb commit ea4fc7c

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

src/darwin/Framework/CHIP/MTRDeviceController.mm

+8-1
Original file line numberDiff line numberDiff line change
@@ -983,9 +983,12 @@ - (BOOL)addServerEndpoint:(MTRServerEndpoint *)endpoint
983983
[self asyncDispatchToMatterQueue:^() {
984984
[self->_serverEndpoints addObject:endpoint];
985985
[endpoint registerMatterEndpoint];
986+
MTR_LOG_DEFAULT("Added server endpoint %u to controller %@", static_cast<chip::EndpointId>(endpoint.endpointID.unsignedLongLongValue),
987+
self->_uniqueIdentifier);
986988
}
987989
errorHandler:^(NSError * error) {
988-
MTR_LOG_ERROR("Unexpected failure dispatching to Matter queue on running controller in addServerEndpoint");
990+
MTR_LOG_ERROR("Unexpected failure dispatching to Matter queue on running controller in addServerEndpoint, adding endpoint %u",
991+
static_cast<chip::EndpointId>(endpoint.endpointID.unsignedLongLongValue));
989992
}];
990993
return YES;
991994
}
@@ -1008,12 +1011,16 @@ - (void)removeServerEndpointInternal:(MTRServerEndpoint *)endpoint queue:(dispat
10081011
// tearing it down.
10091012
[self asyncDispatchToMatterQueue:^() {
10101013
[self removeServerEndpointOnMatterQueue:endpoint];
1014+
MTR_LOG_DEFAULT("Removed server endpoint %u from controller %@", static_cast<chip::EndpointId>(endpoint.endpointID.unsignedLongLongValue),
1015+
self->_uniqueIdentifier);
10111016
if (queue != nil && completion != nil) {
10121017
dispatch_async(queue, completion);
10131018
}
10141019
}
10151020
errorHandler:^(NSError * error) {
10161021
// Error means we got shut down, so the endpoint is removed now.
1022+
MTR_LOG_DEFAULT("controller %@ already shut down, so endpoint %u has already been removed", self->_uniqueIdentifier,
1023+
static_cast<chip::EndpointId>(endpoint.endpointID.unsignedLongLongValue));
10171024
if (queue != nil && completion != nil) {
10181025
dispatch_async(queue, completion);
10191026
}

src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute.mm

+9
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ - (BOOL)setValueInternal:(NSDictionary<NSString *, id> *)value logIfNotAssociate
137137

138138
_value = [value copy];
139139

140+
MTR_LOG_DEFAULT("Attribute value updated: %@", self); // Logs new as part of our description.
141+
140142
MTRDeviceController * deviceController = _deviceController;
141143
if (deviceController == nil) {
142144
// We're not bound to a controller, so safe to directly update
@@ -183,6 +185,8 @@ - (BOOL)associateWithController:(nullable MTRDeviceController *)controller
183185

184186
_deviceController = controller;
185187

188+
MTR_LOG_DEFAULT("Associated %@ with controller", self);
189+
186190
return YES;
187191
}
188192

@@ -218,4 +222,9 @@ - (void)updateParentCluster:(const app::ConcreteClusterPath &)cluster
218222
return _parentCluster;
219223
}
220224

225+
- (NSString *)description
226+
{
227+
return [NSString stringWithFormat:@"<MTRServerAttribute endpoint %u, cluster " ChipLogFormatMEI ", id " ChipLogFormatMEI ", value '%@'>", static_cast<EndpointId>(_parentCluster.mEndpointId), ChipLogValueMEI(_parentCluster.mClusterId), ChipLogValueMEI(_attributeID.unsignedLongLongValue), _value];
228+
}
229+
221230
@end

src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.mm

+9
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ - (BOOL)associateWithController:(nullable MTRDeviceController *)controller
313313

314314
_deviceController = controller;
315315

316+
MTR_LOG_DEFAULT("Associated %@, attribute count %llu, with controller", self,
317+
static_cast<unsigned long long>(attributeCount));
318+
316319
return YES;
317320
}
318321

@@ -408,6 +411,12 @@ - (CommandId *)matterGeneratedCommands
408411
return matterCommandList;
409412
}
410413

414+
- (NSString *)description
415+
{
416+
return [NSString stringWithFormat:@"<MTRServerCluster endpoint %u, id " ChipLogFormatMEI ">",
417+
_parentEndpoint, ChipLogValueMEI(_clusterID.unsignedLongLongValue)];
418+
}
419+
411420
@end
412421

413422
CHIP_ERROR MTRServerAttributeAccessInterface::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder)

src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.mm

+8
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ - (BOOL)finishAssociationWithController:(nullable MTRDeviceController *)controll
317317

318318
_deviceController = controller;
319319

320+
MTR_LOG_DEFAULT("Associated %@, cluster count %llu, with controller",
321+
self, static_cast<unsigned long long>(clusterCount));
322+
320323
return YES;
321324
}
322325

@@ -415,4 +418,9 @@ - (void)invalidate
415418
return [_serverClusters copy];
416419
}
417420

421+
- (NSString *)description
422+
{
423+
return [NSString stringWithFormat:@"<MTRServerEndpoint id %u>", static_cast<EndpointId>(_endpointID.unsignedLongLongValue)];
424+
}
425+
418426
@end

0 commit comments

Comments
 (0)