Skip to content

Commit

Permalink
improve MTRDeviceController/_Concrete (#35060)
Browse files Browse the repository at this point in the history
logging
  • Loading branch information
kiel-apple authored and pull[bot] committed Aug 30, 2024
1 parent 78f550e commit 1440616
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions src/darwin/Framework/CHIP/MTRDeviceController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ - (instancetype)initWithFactory:(MTRDeviceControllerFactory *)factory

- (NSString *)description
{
return [NSString stringWithFormat:@"<MTRDeviceController: %p uuid %@>", self, _uniqueIdentifier];
return [NSString stringWithFormat:@"<%@: %p uuid %@>", NSStringFromClass(self.class), self, _uniqueIdentifier];
}

- (BOOL)isRunning
Expand All @@ -322,7 +322,7 @@ - (void)shutdown
return;
}

MTR_LOG("Shutting down MTRDeviceController: %@", self);
MTR_LOG("Shutting down %@: %@", NSStringFromClass(self.class), self);
[self cleanupAfterStartup];
}

Expand All @@ -334,7 +334,7 @@ - (void)cleanupAfterStartup
// do the secure session shutdowns. Since we don't want to hold the lock
// while calling out into arbitrary invalidation code, snapshot the list of
// devices before we start invalidating.
MTR_LOG("cleanupAfterStartup MTRDeviceController: %@", self);
MTR_LOG("%s: %@", __PRETTY_FUNCTION__, self);
os_unfair_lock_lock(self.deviceMapLock);
NSEnumerator * devices = [_nodeIDToDeviceMap objectEnumerator];
[_nodeIDToDeviceMap removeAllObjects];
Expand All @@ -352,7 +352,7 @@ - (void)cleanupAfterStartup
// in a very specific way that only MTRDeviceControllerFactory knows about.
- (void)shutDownCppController
{
MTR_LOG("shutDownCppController MTRDeviceController: %p", self);
MTR_LOG("%s: %p", __PRETTY_FUNCTION__, self);
assertChipStackLockedByCurrentThread();

// Shut down all our endpoints.
Expand Down Expand Up @@ -659,7 +659,7 @@ - (BOOL)startup:(MTRDeviceControllerStartupParamsInternal *)startupParams
});
}];
}
MTR_LOG("MTRDeviceController startup: %@", self);
MTR_LOG("%@ startup: %@", NSStringFromClass(self.class), self);

return YES;
}
Expand Down Expand Up @@ -1174,7 +1174,7 @@ - (BOOL)addServerEndpoint:(MTRServerEndpoint *)endpoint
}

if (![endpoint associateWithController:self]) {
MTR_LOG_ERROR("%@ Failed to associate MTRServerEndpoint with MTRDeviceController", self);
MTR_LOG_ERROR("%@ Failed to associate MTRServerEndpoint with %@", self, NSStringFromClass(self.class));
[_factory removeServerEndpoint:endpoint];
return NO;
}
Expand Down Expand Up @@ -1294,7 +1294,7 @@ - (BOOL)checkIsRunning:(NSError * __autoreleasing *)error
return YES;
}

MTR_LOG_ERROR("MTRDeviceController: %@ Error: %s", self, [kErrorNotRunning UTF8String]);
MTR_LOG_ERROR("%@: %@ Error: %s", NSStringFromClass(self.class), self, [kErrorNotRunning UTF8String]);
if (error) {
*error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE];
}
Expand Down
16 changes: 8 additions & 8 deletions src/darwin/Framework/CHIP/MTRDeviceController_Concrete.mm
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ - (instancetype)initWithFactory:(MTRDeviceControllerFactory *)factory

- (NSString *)description
{
return [NSString stringWithFormat:@"<MTRDeviceController: %p uuid %@>", self, _uniqueIdentifier];
return [NSString stringWithFormat:@"<%@: %p uuid %@>", NSStringFromClass(self.class), self, _uniqueIdentifier];
}

- (BOOL)isRunning
Expand All @@ -333,7 +333,7 @@ - (void)shutdown
return;
}

MTR_LOG("Shutting down MTRDeviceController: %@", self);
MTR_LOG("Shutting down %@: %@", NSStringFromClass(self.class), self);
[self cleanupAfterStartup];
}

Expand All @@ -345,7 +345,7 @@ - (void)cleanupAfterStartup
// do the secure session shutdowns. Since we don't want to hold the lock
// while calling out into arbitrary invalidation code, snapshot the list of
// devices before we start invalidating.
MTR_LOG("cleanupAfterStartup MTRDeviceController: %@", self);
MTR_LOG("%s: %@", __PRETTY_FUNCTION__, self);
os_unfair_lock_lock(self.deviceMapLock);
NSEnumerator * devices = [self.nodeIDToDeviceMap objectEnumerator];
[self.nodeIDToDeviceMap removeAllObjects];
Expand All @@ -363,7 +363,7 @@ - (void)cleanupAfterStartup
// in a very specific way that only MTRDeviceControllerFactory knows about.
- (void)shutDownCppController
{
MTR_LOG("shutDownCppController MTRDeviceController: %p", self);
MTR_LOG("%s: %p", __PRETTY_FUNCTION__, self);
assertChipStackLockedByCurrentThread();

// Shut down all our endpoints.
Expand Down Expand Up @@ -668,7 +668,7 @@ - (BOOL)startup:(MTRDeviceControllerStartupParamsInternal *)startupParams
});
}];
}
MTR_LOG("MTRDeviceController startup: %@", self);
MTR_LOG("%s: startup: %@", __PRETTY_FUNCTION__, self);

return YES;
}
Expand Down Expand Up @@ -1020,7 +1020,7 @@ - (MTRDevice *)_setupDeviceForNodeID:(NSNumber *)nodeID prefetchedClusterData:(N
{
os_unfair_lock_assert_owner(self.deviceMapLock);

MTRDevice * deviceToReturn = [[MTRDevice alloc] initWithNodeID:nodeID controller:self];
MTRDevice * deviceToReturn = [[MTRDevice_Concrete alloc] initWithNodeID:nodeID controller:self];
// If we're not running, don't add the device to our map. That would
// create a cycle that nothing would break. Just return the device,
// which will be in exactly the state it would be in if it were created
Expand Down Expand Up @@ -1183,7 +1183,7 @@ - (BOOL)addServerEndpoint:(MTRServerEndpoint *)endpoint
}

if (![endpoint associateWithController:self]) {
MTR_LOG_ERROR("%@ Failed to associate MTRServerEndpoint with MTRDeviceController", self);
MTR_LOG_ERROR("%@ Failed to associate MTRServerEndpoint with %@", self, NSStringFromClass(self.class));
[_factory removeServerEndpoint:endpoint];
return NO;
}
Expand Down Expand Up @@ -1303,7 +1303,7 @@ - (BOOL)checkIsRunning:(NSError * __autoreleasing *)error
return YES;
}

MTR_LOG_ERROR("MTRDeviceController: %@ Error: %s", self, [kDeviceControllerErrorNotRunning UTF8String]);
MTR_LOG_ERROR("%@: %@ Error: %s", NSStringFromClass(self.class), self, [kDeviceControllerErrorNotRunning UTF8String]);
if (error) {
*error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE];
}
Expand Down

0 comments on commit 1440616

Please sign in to comment.