Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve logging around sending XPC messages. #37480

Merged
merged 1 commit into from
Feb 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/darwin/Framework/CHIP/MTRDefines_Internal.h
Original file line number Diff line number Diff line change
@@ -86,13 +86,14 @@ typedef struct {} variable_hidden_by_mtr_hide;
\
@try { \
[[xpcConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { \
MTR_LOG_ERROR("Error: %@", error); \
MTR_LOG_ERROR("%@ Error in %@ getter: %@", self, NSStringFromSelector(_cmd), error); \
}] PREFIX \
GETTER_NAME:^(TYPE returnValue) { \
outValue = returnValue; \
}]; \
} @catch (NSException * exception) { \
MTR_LOG_ERROR("Exception sending XPC messsage: %@", exception); \
MTR_LOG_ERROR("%@ Exception sending XPC messsage for %@ getter: %@", self, \
NSStringFromSelector(_cmd), exception); \
outValue = DEFAULT_VALUE; \
} \
return outValue; \
@@ -106,10 +107,11 @@ typedef struct {} variable_hidden_by_mtr_hide;
\
@try { \
[[xpcConnection remoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { \
MTR_LOG_ERROR("Error: %@", error); \
MTR_LOG_ERROR("%@ Error in %@: %@", self, NSStringFromSelector(_cmd), error); \
}] PREFIX ADDITIONAL_ARGUMENTS]; \
} @catch (NSException * exception) { \
MTR_LOG_ERROR("Exception sending XPC messsage: %@", exception); \
MTR_LOG_ERROR("%@ Exception sending XPC messsage for %@: %@", self, \
NSStringFromSelector(_cmd), exception); \
} \
}

@@ -122,12 +124,13 @@ typedef struct {} variable_hidden_by_mtr_hide;
\
@try { \
[[xpcConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { \
MTR_LOG_ERROR("Error: %@", error); \
MTR_LOG_ERROR("%@ Error in %@: %@", self, NSStringFromSelector(_cmd), error); \
}] PREFIX ADDITIONAL_ARGUMENTS:^(TYPE returnValue) { \
outValue = returnValue; \
}]; \
} @catch (NSException * exception) { \
MTR_LOG_ERROR("Exception sending XPC messsage: %@", exception); \
MTR_LOG_ERROR("%@ Exception sending XPC messsage for %@: %@", self, NSStringFromSelector(_cmd), \
exception); \
outValue = DEFAULT_VALUE; \
} \
\
8 changes: 4 additions & 4 deletions src/darwin/Framework/CHIP/MTRDevice_XPC.mm
Original file line number Diff line number Diff line change
@@ -467,7 +467,7 @@ - (void)invokeCommands:(NSArray<NSArray<MTRCommandWithRequiredResponse *> *> *)c

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

@try {
[[xpcConnection remoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) {
MTR_LOG_ERROR("Error: %@", error);
MTR_LOG_ERROR("%@ Error in %@: %@", self, NSStringFromSelector(_cmd), error);
dispatch_async(queue, ^{
completion(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeGeneralError userInfo:nil]);
});
@@ -538,7 +538,7 @@ - (void)downloadLogOfType:(MTRDiagnosticLogType)type
});
}];
} @catch (NSException * exception) {
MTR_LOG_ERROR("Exception sending XPC messsage: %@", exception);
MTR_LOG_ERROR("%@ Exception sending XPC messsage for %@: %@", self, NSStringFromSelector(_cmd), exception);
dispatch_async(queue, ^{
completion(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeGeneralError userInfo:nil]);
});