Skip to content

Commit caaef7c

Browse files
bzbarsky-applepimpalemahesh
authored andcommitted
Improve logging around sending XPC messages. (project-chip#37480)
Log self and the method involved, so we know what's failing on what objects.
1 parent f2c2dda commit caaef7c

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/darwin/Framework/CHIP/MTRDefines_Internal.h

+9-6
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,14 @@ typedef struct {} variable_hidden_by_mtr_hide;
8686
\
8787
@try { \
8888
[[xpcConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { \
89-
MTR_LOG_ERROR("Error: %@", error); \
89+
MTR_LOG_ERROR("%@ Error in %@ getter: %@", self, NSStringFromSelector(_cmd), error); \
9090
}] PREFIX \
9191
GETTER_NAME:^(TYPE returnValue) { \
9292
outValue = returnValue; \
9393
}]; \
9494
} @catch (NSException * exception) { \
95-
MTR_LOG_ERROR("Exception sending XPC messsage: %@", exception); \
95+
MTR_LOG_ERROR("%@ Exception sending XPC messsage for %@ getter: %@", self, \
96+
NSStringFromSelector(_cmd), exception); \
9697
outValue = DEFAULT_VALUE; \
9798
} \
9899
return outValue; \
@@ -106,10 +107,11 @@ typedef struct {} variable_hidden_by_mtr_hide;
106107
\
107108
@try { \
108109
[[xpcConnection remoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { \
109-
MTR_LOG_ERROR("Error: %@", error); \
110+
MTR_LOG_ERROR("%@ Error in %@: %@", self, NSStringFromSelector(_cmd), error); \
110111
}] PREFIX ADDITIONAL_ARGUMENTS]; \
111112
} @catch (NSException * exception) { \
112-
MTR_LOG_ERROR("Exception sending XPC messsage: %@", exception); \
113+
MTR_LOG_ERROR("%@ Exception sending XPC messsage for %@: %@", self, \
114+
NSStringFromSelector(_cmd), exception); \
113115
} \
114116
}
115117

@@ -122,12 +124,13 @@ typedef struct {} variable_hidden_by_mtr_hide;
122124
\
123125
@try { \
124126
[[xpcConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { \
125-
MTR_LOG_ERROR("Error: %@", error); \
127+
MTR_LOG_ERROR("%@ Error in %@: %@", self, NSStringFromSelector(_cmd), error); \
126128
}] PREFIX ADDITIONAL_ARGUMENTS:^(TYPE returnValue) { \
127129
outValue = returnValue; \
128130
}]; \
129131
} @catch (NSException * exception) { \
130-
MTR_LOG_ERROR("Exception sending XPC messsage: %@", exception); \
132+
MTR_LOG_ERROR("%@ Exception sending XPC messsage for %@: %@", self, NSStringFromSelector(_cmd), \
133+
exception); \
131134
outValue = DEFAULT_VALUE; \
132135
} \
133136
\

src/darwin/Framework/CHIP/MTRDevice_XPC.mm

+4-4
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ - (void)invokeCommands:(NSArray<NSArray<MTRCommandWithRequiredResponse *> *> *)c
467467

468468
@try {
469469
[[xpcConnection remoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) {
470-
MTR_LOG_ERROR("Error: %@", error);
470+
MTR_LOG_ERROR("%@ Error in %@: %@", self, NSStringFromSelector(_cmd), error);
471471
dispatch_async(queue, ^{
472472
completion(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeGeneralError userInfo:nil]);
473473
});
@@ -505,7 +505,7 @@ - (void)invokeCommands:(NSArray<NSArray<MTRCommandWithRequiredResponse *> *> *)c
505505
});
506506
}];
507507
} @catch (NSException * exception) {
508-
MTR_LOG_ERROR("Exception sending XPC message: %@", exception);
508+
MTR_LOG_ERROR("%@ Exception sending XPC message for %@: %@", self, NSStringFromSelector(_cmd), exception);
509509
dispatch_async(queue, ^{
510510
completion(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeGeneralError userInfo:nil]);
511511
});
@@ -521,7 +521,7 @@ - (void)downloadLogOfType:(MTRDiagnosticLogType)type
521521

522522
@try {
523523
[[xpcConnection remoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) {
524-
MTR_LOG_ERROR("Error: %@", error);
524+
MTR_LOG_ERROR("%@ Error in %@: %@", self, NSStringFromSelector(_cmd), error);
525525
dispatch_async(queue, ^{
526526
completion(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeGeneralError userInfo:nil]);
527527
});
@@ -538,7 +538,7 @@ - (void)downloadLogOfType:(MTRDiagnosticLogType)type
538538
});
539539
}];
540540
} @catch (NSException * exception) {
541-
MTR_LOG_ERROR("Exception sending XPC messsage: %@", exception);
541+
MTR_LOG_ERROR("%@ Exception sending XPC messsage for %@: %@", self, NSStringFromSelector(_cmd), exception);
542542
dispatch_async(queue, ^{
543543
completion(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeGeneralError userInfo:nil]);
544544
});

0 commit comments

Comments
 (0)