Skip to content

Commit b7b6738

Browse files
authored
improve MTRDeviceController/_Concrete (project-chip#35060)
logging
1 parent baba33d commit b7b6738

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/darwin/Framework/CHIP/MTRDeviceController.mm

+7-7
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ - (instancetype)initWithFactory:(MTRDeviceControllerFactory *)factory
306306

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

312312
- (BOOL)isRunning
@@ -322,7 +322,7 @@ - (void)shutdown
322322
return;
323323
}
324324

325-
MTR_LOG("Shutting down MTRDeviceController: %@", self);
325+
MTR_LOG("Shutting down %@: %@", NSStringFromClass(self.class), self);
326326
[self cleanupAfterStartup];
327327
}
328328

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

358358
// Shut down all our endpoints.
@@ -659,7 +659,7 @@ - (BOOL)startup:(MTRDeviceControllerStartupParamsInternal *)startupParams
659659
});
660660
}];
661661
}
662-
MTR_LOG("MTRDeviceController startup: %@", self);
662+
MTR_LOG("%@ startup: %@", NSStringFromClass(self.class), self);
663663

664664
return YES;
665665
}
@@ -1174,7 +1174,7 @@ - (BOOL)addServerEndpoint:(MTRServerEndpoint *)endpoint
11741174
}
11751175

11761176
if (![endpoint associateWithController:self]) {
1177-
MTR_LOG_ERROR("%@ Failed to associate MTRServerEndpoint with MTRDeviceController", self);
1177+
MTR_LOG_ERROR("%@ Failed to associate MTRServerEndpoint with %@", self, NSStringFromClass(self.class));
11781178
[_factory removeServerEndpoint:endpoint];
11791179
return NO;
11801180
}
@@ -1294,7 +1294,7 @@ - (BOOL)checkIsRunning:(NSError * __autoreleasing *)error
12941294
return YES;
12951295
}
12961296

1297-
MTR_LOG_ERROR("MTRDeviceController: %@ Error: %s", self, [kErrorNotRunning UTF8String]);
1297+
MTR_LOG_ERROR("%@: %@ Error: %s", NSStringFromClass(self.class), self, [kErrorNotRunning UTF8String]);
12981298
if (error) {
12991299
*error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE];
13001300
}

src/darwin/Framework/CHIP/MTRDeviceController_Concrete.mm

+8-8
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ - (instancetype)initWithFactory:(MTRDeviceControllerFactory *)factory
317317

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

323323
- (BOOL)isRunning
@@ -333,7 +333,7 @@ - (void)shutdown
333333
return;
334334
}
335335

336-
MTR_LOG("Shutting down MTRDeviceController: %@", self);
336+
MTR_LOG("Shutting down %@: %@", NSStringFromClass(self.class), self);
337337
[self cleanupAfterStartup];
338338
}
339339

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

369369
// Shut down all our endpoints.
@@ -668,7 +668,7 @@ - (BOOL)startup:(MTRDeviceControllerStartupParamsInternal *)startupParams
668668
});
669669
}];
670670
}
671-
MTR_LOG("MTRDeviceController startup: %@", self);
671+
MTR_LOG("%s: startup: %@", __PRETTY_FUNCTION__, self);
672672

673673
return YES;
674674
}
@@ -1020,7 +1020,7 @@ - (MTRDevice *)_setupDeviceForNodeID:(NSNumber *)nodeID prefetchedClusterData:(N
10201020
{
10211021
os_unfair_lock_assert_owner(self.deviceMapLock);
10221022

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

11851185
if (![endpoint associateWithController:self]) {
1186-
MTR_LOG_ERROR("%@ Failed to associate MTRServerEndpoint with MTRDeviceController", self);
1186+
MTR_LOG_ERROR("%@ Failed to associate MTRServerEndpoint with %@", self, NSStringFromClass(self.class));
11871187
[_factory removeServerEndpoint:endpoint];
11881188
return NO;
11891189
}
@@ -1303,7 +1303,7 @@ - (BOOL)checkIsRunning:(NSError * __autoreleasing *)error
13031303
return YES;
13041304
}
13051305

1306-
MTR_LOG_ERROR("MTRDeviceController: %@ Error: %s", self, [kDeviceControllerErrorNotRunning UTF8String]);
1306+
MTR_LOG_ERROR("%@: %@ Error: %s", NSStringFromClass(self.class), self, [kDeviceControllerErrorNotRunning UTF8String]);
13071307
if (error) {
13081308
*error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE];
13091309
}

0 commit comments

Comments
 (0)