improve `MTRDeviceController`/`_Concrete` (#35060)
logging
diff --git a/src/darwin/Framework/CHIP/MTRDeviceController.mm b/src/darwin/Framework/CHIP/MTRDeviceController.mm
index bfbb62f..3225933 100644
--- a/src/darwin/Framework/CHIP/MTRDeviceController.mm
+++ b/src/darwin/Framework/CHIP/MTRDeviceController.mm
@@ -306,7 +306,7 @@
- (NSString *)description
{
- return [NSString stringWithFormat:@"<MTRDeviceController: %p uuid %@>", self, _uniqueIdentifier];
+ return [NSString stringWithFormat:@"<%@: %p uuid %@>", NSStringFromClass(self.class), self, _uniqueIdentifier];
}
- (BOOL)isRunning
@@ -322,7 +322,7 @@
return;
}
- MTR_LOG("Shutting down MTRDeviceController: %@", self);
+ MTR_LOG("Shutting down %@: %@", NSStringFromClass(self.class), self);
[self cleanupAfterStartup];
}
@@ -334,7 +334,7 @@
// 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];
@@ -352,7 +352,7 @@
// 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.
@@ -659,7 +659,7 @@
});
}];
}
- MTR_LOG("MTRDeviceController startup: %@", self);
+ MTR_LOG("%@ startup: %@", NSStringFromClass(self.class), self);
return YES;
}
@@ -1174,7 +1174,7 @@
}
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;
}
@@ -1294,7 +1294,7 @@
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];
}
diff --git a/src/darwin/Framework/CHIP/MTRDeviceController_Concrete.mm b/src/darwin/Framework/CHIP/MTRDeviceController_Concrete.mm
index b3152a9..0ea7bf9 100644
--- a/src/darwin/Framework/CHIP/MTRDeviceController_Concrete.mm
+++ b/src/darwin/Framework/CHIP/MTRDeviceController_Concrete.mm
@@ -317,7 +317,7 @@
- (NSString *)description
{
- return [NSString stringWithFormat:@"<MTRDeviceController: %p uuid %@>", self, _uniqueIdentifier];
+ return [NSString stringWithFormat:@"<%@: %p uuid %@>", NSStringFromClass(self.class), self, _uniqueIdentifier];
}
- (BOOL)isRunning
@@ -333,7 +333,7 @@
return;
}
- MTR_LOG("Shutting down MTRDeviceController: %@", self);
+ MTR_LOG("Shutting down %@: %@", NSStringFromClass(self.class), self);
[self cleanupAfterStartup];
}
@@ -345,7 +345,7 @@
// 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];
@@ -363,7 +363,7 @@
// 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.
@@ -668,7 +668,7 @@
});
}];
}
- MTR_LOG("MTRDeviceController startup: %@", self);
+ MTR_LOG("%s: startup: %@", __PRETTY_FUNCTION__, self);
return YES;
}
@@ -1020,7 +1020,7 @@
{
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
@@ -1183,7 +1183,7 @@
}
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;
}
@@ -1303,7 +1303,7 @@
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];
}