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

Add better logging to downloadLogOfType in Matter.framework. #37830

Merged
Merged
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion src/darwin/Framework/CHIP/MTRDevice_Concrete.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3759,11 +3759,19 @@ - (void)downloadLogOfType:(MTRDiagnosticLogType)type
queue:(dispatch_queue_t)queue
completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
{
MTR_LOG("%@ downloadLogOfType: %lu, timeout: %f", self, static_cast<unsigned long>(type), timeout);

auto * baseDevice = [self newBaseDevice];

mtr_weakify(self);
[baseDevice downloadLogOfType:type
timeout:timeout
queue:queue
completion:completion];
completion:^(NSURL * _Nullable url, NSError * _Nullable error) {
mtr_strongify(self);
MTR_LOG("%@ downloadLogOfType %lu completed: %@", self, static_cast<unsigned long>(type), error);
completion(url, error);
}];
}

#pragma mark - Cache management
Expand Down
35 changes: 32 additions & 3 deletions src/darwin/Framework/CHIP/MTRDiagnosticLogsDownloader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <protocols/bdx/BdxTransferServerDelegate.h>
#include <protocols/bdx/DiagnosticLogs.h>

#import "MTRDeviceControllerFactory_Internal.h"
#import "MTRDeviceController_Internal.h"
#import "MTRError_Internal.h"
#import "MTRLogging_Internal.h"
Expand Down Expand Up @@ -260,6 +261,7 @@ - (BOOL)matches:(NSString *)fileDesignator

- (void)failure:(NSError * _Nullable)error
{
MTR_LOG("%@ Diagnostic log transfer failure: %@", self, error);
_finalize(error);
}

Expand Down Expand Up @@ -461,6 +463,9 @@ - (void)downloadLogFromNodeWithID:(NSNumber *)nodeID
auto err = _bridge->StartBDXTransferTimeout(download, timeoutInSeconds);
VerifyOrReturn(CHIP_NO_ERROR == err, [download failure:[MTRError errorForCHIPErrorCode:err]]);
}

MTR_LOG("%@ Started log download attempt for node %016llX-%016llX (%llu)", download,
controller.compressedFabricID.unsignedLongLongValue, nodeID.unsignedLongLongValue, nodeID.unsignedLongLongValue);
}

- (void)abortDownloadsForController:(MTRDeviceController_Concrete *)controller;
Expand All @@ -477,9 +482,15 @@ - (void)handleBDXTransferSessionBeginForFileDesignator:(NSString *)fileDesignato
abortHandler:(AbortHandler)abortHandler;
{
assertChipStackLockedByCurrentThread();
MTR_LOG("BDX Transfer Session Begin for log download: %@", fileDesignator);

auto * download = [_downloads get:fileDesignator fabricIndex:fabricIndex nodeID:nodeID];

auto * controller = [[MTRDeviceControllerFactory sharedInstance] runningControllerForFabricIndex:fabricIndex.unsignedCharValue];

MTR_LOG("%@ BDX Transfer Session Begin for log download: %016llX-%016llX (%llu), %@", download,
controller.compressedFabricID.unsignedLongLongValue, nodeID.unsignedLongLongValue, nodeID.unsignedLongLongValue,
fileDesignator);

VerifyOrReturn(nil != download, completion([MTRError errorForCHIPErrorCode:CHIP_ERROR_NOT_FOUND]));

download.abortHandler = abortHandler;
Expand All @@ -493,9 +504,15 @@ - (void)handleBDXTransferSessionDataForFileDesignator:(NSString *)fileDesignator
completion:(MTRStatusCompletion)completion
{
assertChipStackLockedByCurrentThread();
MTR_LOG("BDX Transfer Session Data for log download: %@: %@", fileDesignator, data);

auto * download = [_downloads get:fileDesignator fabricIndex:fabricIndex nodeID:nodeID];

auto * controller = [[MTRDeviceControllerFactory sharedInstance] runningControllerForFabricIndex:fabricIndex.unsignedCharValue];

MTR_LOG("%@ BDX Transfer Session Data for log download: %016llX-%016llX (%llu), %@: %@", download,
controller.compressedFabricID.unsignedLongLongValue, nodeID.unsignedLongLongValue, nodeID.unsignedLongLongValue,
fileDesignator, data);

VerifyOrReturn(nil != download, completion([MTRError errorForCHIPErrorCode:CHIP_ERROR_NOT_FOUND]));

NSError * error = nil;
Expand All @@ -511,9 +528,15 @@ - (void)handleBDXTransferSessionEndForFileDesignator:(NSString *)fileDesignator
error:(NSError * _Nullable)error
{
assertChipStackLockedByCurrentThread();
MTR_LOG("BDX Transfer Session End for log download: %@: %@", fileDesignator, error);

auto * download = [_downloads get:fileDesignator fabricIndex:fabricIndex nodeID:nodeID];

auto * controller = [[MTRDeviceControllerFactory sharedInstance] runningControllerForFabricIndex:fabricIndex.unsignedCharValue];

MTR_LOG("%@ BDX Transfer Session End for log download: %016llX-%016llX (%llu), %@: %@", download,
controller.compressedFabricID.unsignedLongLongValue, nodeID.unsignedLongLongValue, nodeID.unsignedLongLongValue,
fileDesignator, error);

VerifyOrReturn(nil != download);

VerifyOrReturn(nil == error, [download failure:error]);
Expand Down Expand Up @@ -641,6 +664,12 @@ - (void)handleBDXTransferSessionEndForFileDesignator:(NSString *)fileDesignator
auto * download = (__bridge MTRDownload *) context;
VerifyOrReturn(nil != download);

auto * controller = [[MTRDeviceControllerFactory sharedInstance] runningControllerForFabricIndex:download.fabricIndex.unsignedCharValue];

MTR_LOG("%@ Diagnostic log transfer timed out for %016llX-%016llX (%llu), abortHandler: %@", download,
controller.compressedFabricID.unsignedLongLongValue, download.nodeID.unsignedLongLongValue,
download.nodeID.unsignedLongLongValue, download.abortHandler);

// If there is no abortHandler, it means that the BDX transfer has not started.
// When a BDX transfer has started we need to abort the transfer and we would error out
// at next poll. We would end up calling OnTransferEnd and eventually [download failure:error].
Expand Down
Loading