Skip to content

Commit 171843d

Browse files
authored
Adding logging to Darwin (project-chip#34241)
* Adding logging so we can debug stuff... * Apply suggestions from code review * Update src/darwin/Framework/CHIP/MTRDevice.mm
1 parent f94ffab commit 171843d

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

examples/darwin-framework-tool/commands/common/CHIPCommandBridge.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CHIPCommandBridge : public Command {
3939
{
4040
AddArgument("commissioner-name", &mCommissionerName);
4141
AddArgument("commissioner-nodeId", 0, UINT64_MAX, &mCommissionerNodeId,
42-
"Sets the commisser node ID of the given "
42+
"Sets the commissioner node ID of the given "
4343
"commissioner-name. Interactive mode will only set a single commissioner on the inital command. "
4444
"The commissioner node ID will be persisted until a different one is specified.");
4545
AddArgument("paa-trust-store-path", &mPaaTrustStorePath,

examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ - (void)controller:(MTRDeviceController *)controller statusUpdate:(MTRCommission
3636
ChipLogError(chipTool, "MTRCommissioningStatusDiscoveringMoreDevices: This should not happen.");
3737
break;
3838
case MTRCommissioningStatusUnknown:
39-
ChipLogError(chipTool, "Uknown Pairing Status");
39+
ChipLogError(chipTool, "Unknown Pairing Status");
4040
break;
4141
}
4242
}

src/darwin/Framework/CHIP/MTRDevice.mm

+5-1
Original file line numberDiff line numberDiff line change
@@ -844,11 +844,13 @@ - (void)_addDelegate:(id<MTRDeviceDelegate>)delegate queue:(dispatch_queue_t)que
844844
#endif
845845

846846
if (shouldSetUpSubscription) {
847+
MTR_LOG("%@ - starting subscription setup", self);
847848
// Record the time of first addDelegate call that triggers initial subscribe, and do not reset this value on subsequent addDelegate calls
848849
if (!_initialSubscribeStart) {
849850
_initialSubscribeStart = [NSDate now];
850851
}
851852
if ([self _deviceUsesThread]) {
853+
MTR_LOG(" => %@ - device is a thread device, scheduling in pool", self);
852854
[self _scheduleSubscriptionPoolWork:^{
853855
std::lock_guard lock(self->_lock);
854856
[self _setupSubscriptionWithReason:@"delegate is set and scheduled subscription is happening"];
@@ -1301,7 +1303,7 @@ - (void)_scheduleSubscriptionPoolWork:(dispatch_block_t)workBlock inNanoseconds:
13011303

13021304
// Sanity check we are not scheduling for this device multiple times in the pool
13031305
if (_subscriptionPoolWorkCompletionBlock) {
1304-
MTR_LOG_ERROR("%@ already scheduled in subscription pool for this device - ignoring: %@", self, description);
1306+
MTR_LOG("%@ already scheduled in subscription pool for this device - ignoring: %@", self, description);
13051307
return;
13061308
}
13071309

@@ -1310,6 +1312,7 @@ - (void)_scheduleSubscriptionPoolWork:(dispatch_block_t)workBlock inNanoseconds:
13101312
// In the case where a resubscription triggering event happened and already established, running the work block should result in a no-op
13111313
MTRAsyncWorkItem * workItem = [[MTRAsyncWorkItem alloc] initWithQueue:self.queue];
13121314
[workItem setReadyHandler:^(id _Nonnull context, NSInteger retryCount, MTRAsyncWorkCompletionBlock _Nonnull completion) {
1315+
MTR_LOG("%@ - work item is ready to attempt pooled subscription", self);
13131316
os_unfair_lock_lock(&self->_lock);
13141317
#ifdef DEBUG
13151318
[self _callDelegatesWithBlock:^(id testDelegate) {
@@ -1335,6 +1338,7 @@ - (void)_scheduleSubscriptionPoolWork:(dispatch_block_t)workBlock inNanoseconds:
13351338
workBlock();
13361339
}];
13371340
[self->_deviceController.concurrentSubscriptionPool enqueueWorkItem:workItem description:description];
1341+
MTR_LOG("%@ - enqueued in the subscription pool", self);
13381342
});
13391343
}
13401344

src/darwin/Framework/CHIP/MTRError_Internal.h

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626

2727
NS_ASSUME_NONNULL_BEGIN
2828

29+
#ifndef YES_NO
30+
#define YES_NO(x) ((x) ? @"YES" : @"NO")
31+
#endif
32+
2933
MTR_DIRECT_MEMBERS
3034
@interface MTRError : NSObject
3135
+ (NSError *)errorWithCode:(MTRErrorCode)code;

0 commit comments

Comments
 (0)