Skip to content

Commit 7386075

Browse files
woody-applelazarkov
authored andcommitted
Adding logging to Darwin (#34241)
* Adding logging so we can debug stuff... * Apply suggestions from code review * Update src/darwin/Framework/CHIP/MTRDevice.mm
1 parent b3c50b2 commit 7386075

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
@@ -841,11 +841,13 @@ - (void)_addDelegate:(id<MTRDeviceDelegate>)delegate queue:(dispatch_queue_t)que
841841
#endif
842842

843843
if (shouldSetUpSubscription) {
844+
MTR_LOG("%@ - starting subscription setup", self);
844845
// Record the time of first addDelegate call that triggers initial subscribe, and do not reset this value on subsequent addDelegate calls
845846
if (!_initialSubscribeStart) {
846847
_initialSubscribeStart = [NSDate now];
847848
}
848849
if ([self _deviceUsesThread]) {
850+
MTR_LOG(" => %@ - device is a thread device, scheduling in pool", self);
849851
[self _scheduleSubscriptionPoolWork:^{
850852
std::lock_guard lock(self->_lock);
851853
[self _setupSubscriptionWithReason:@"delegate is set and scheduled subscription is happening"];
@@ -1298,7 +1300,7 @@ - (void)_scheduleSubscriptionPoolWork:(dispatch_block_t)workBlock inNanoseconds:
12981300

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

@@ -1307,6 +1309,7 @@ - (void)_scheduleSubscriptionPoolWork:(dispatch_block_t)workBlock inNanoseconds:
13071309
// In the case where a resubscription triggering event happened and already established, running the work block should result in a no-op
13081310
MTRAsyncWorkItem * workItem = [[MTRAsyncWorkItem alloc] initWithQueue:self.queue];
13091311
[workItem setReadyHandler:^(id _Nonnull context, NSInteger retryCount, MTRAsyncWorkCompletionBlock _Nonnull completion) {
1312+
MTR_LOG("%@ - work item is ready to attempt pooled subscription", self);
13101313
os_unfair_lock_lock(&self->_lock);
13111314
#ifdef DEBUG
13121315
[self _callDelegatesWithBlock:^(id testDelegate) {
@@ -1332,6 +1335,7 @@ - (void)_scheduleSubscriptionPoolWork:(dispatch_block_t)workBlock inNanoseconds:
13321335
workBlock();
13331336
}];
13341337
[self->_deviceController.concurrentSubscriptionPool enqueueWorkItem:workItem description:description];
1338+
MTR_LOG("%@ - enqueued in the subscription pool", self);
13351339
});
13361340
}
13371341

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)