Skip to content

Commit

Permalink
fixup! DEBUG: logging
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight committed Aug 28, 2023
1 parent e951073 commit fc06dbb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 30 additions & 1 deletion Sources/Sentry/SentryBreadcrumbTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ - (instancetype)initWithSwizzleWrapper:(SentrySwizzleWrapper *)swizzleWrapper

- (void)startWithDelegate:(id<SentryBreadcrumbDelegate>)delegate
{
NSLog(@"Starting %@ with delegate: %@", self, delegate);
_delegate = delegate;
[self addEnabledCrumb];
[self trackApplicationUIKitNotifications];
Expand Down Expand Up @@ -201,14 +202,42 @@ - (void)swizzleViewDidAppear
static const void *swizzleViewDidAppearKey = &swizzleViewDidAppearKey;
SEL selector = NSSelectorFromString(@"viewDidAppear:");
__weak id<SentryBreadcrumbDelegate> delegate = self.delegate;
SentryBreadcrumbTracker *__weak tracker = self;

// [SentrySwizzle
// swizzleInstanceMethod:selector
// inClass:UIViewController.class
// newImpFactory:^id(SentrySwizzleInfo *swizzleInfo) {
// return ^(__unsafe_unretained id self,
// BOOL animated) {
// SentryBreadcrumb *crumb = [[SentryBreadcrumb alloc]
// initWithLevel:kSentryLevelInfo
// category:@"ui.lifecycle"];
// crumb.type = @"navigation";
// crumb.data = [SentryBreadcrumbTracker
// fetchInfoAboutViewController:self];
//
// NSLog(@"tracker: %@; __weak id<SentryBreadcrumbDelegate>: %@; crumb:
// %@", tracker, delegate, crumb);
//
// [delegate addBreadcrumb:crumb];
//
// ((void (*)(__unsafe_unretained id, SEL))[swizzleInfo
// getOriginalImplementation])(self, selector);
// };
// }
// mode:SentrySwizzleModeOncePerClassAndSuperclasses
// key:swizzleViewDidAppearKey];

SentrySwizzleInstanceMethod(UIViewController.class, selector, SentrySWReturnType(void),
SentrySWArguments(BOOL animated), SentrySWReplacement({
SentryBreadcrumb *crumb = [[SentryBreadcrumb alloc] initWithLevel:kSentryLevelInfo
category:@"ui.lifecycle"];
crumb.type = @"navigation";
crumb.data = [SentryBreadcrumbTracker fetchInfoAboutViewController:self];

NSLog(@"__weak id<SentryBreadcrumbDelegate>: %@; crumb: %@", delegate, crumb);
NSLog(@"tracker: %@; __weak id<SentryBreadcrumbDelegate>: %@; crumb: %@", tracker,
delegate, crumb);

[delegate addBreadcrumb:crumb];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class SentryBreadcrumbTrackerTests: XCTestCase {
let viewController = UIViewController()
_ = UINavigationController(rootViewController: viewController)
viewController.title = "test title"
print("delegate: \(String(describing: delegate))")
print("tracker: \(sut); SentryBreadcrumbTracker.delegate: \(String(describing: Dynamic(sut).delegate.asObject))")
viewController.viewDidAppear(false)

let crumbs = delegate.addCrumbInvocations.invocations
Expand Down

0 comments on commit fc06dbb

Please sign in to comment.