Skip to content

Commit 57989f4

Browse files
committed
chore: cleanup logs
1 parent decfb98 commit 57989f4

File tree

3 files changed

+75
-90
lines changed

3 files changed

+75
-90
lines changed

β€ŽNativeScript/runtime/Console.cppβ€Ž

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ void Console::LogCallback(const FunctionCallbackInfo<Value>& args) {
106106
stackTraceLines << std::endl << stacktrace << std::endl;
107107

108108
std::string errorToDisplay = stackTraceLines.str();
109-
Log("BEFORE mapped errorToDisplay %s", errorToDisplay.c_str());
110109

111110
// Extract error details
112111
std::string errorTitle = "JavaScript Error";
@@ -124,7 +123,6 @@ void Console::LogCallback(const FunctionCallbackInfo<Value>& args) {
124123
.ToLocal(&remapStackValue);
125124

126125
if (success && remapStackValue->IsFunction()) {
127-
Log("remapStackValue is a function!");
128126
Local<v8::Function> remapStackFunction =
129127
remapStackValue.As<v8::Function>();
130128

@@ -143,8 +141,6 @@ void Console::LogCallback(const FunctionCallbackInfo<Value>& args) {
143141
}
144142
}
145143

146-
Log("AFTER mapped errorToDisplay %s", errorToDisplay.c_str());
147-
148144
try {
149145
NativeScriptException::ShowErrorModal(errorTitle, errorToDisplay,
150146
errorToDisplay);

β€ŽNativeScript/runtime/NativeScriptException.mmβ€Ž

Lines changed: 70 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@
126126
if (RuntimeConfig.IsDebug) {
127127
// Mark that a JavaScript error occurred
128128
jsErrorOccurred = true;
129-
NSLog(@"***** JavaScript exception occurred - showing beautiful NativeScript error modal "
129+
NSLog(@"***** JavaScript exception occurred "
130130
@"in debug mode *****\n");
131131
NSLog(@"%@", reasonStr);
132-
NSLog(@"🎨 CALLING ShowErrorModal for OnUncaughtError - should display beautiful branded "
133-
@"modal...");
132+
// NSLog(@"🎨 CALLING ShowErrorModal for OnUncaughtError - should display beautiful branded "
133+
// @"modal...");
134134

135135
// Show the beautiful error modal with SAME comprehensive message as terminal
136136
std::string errorTitle = "Uncaught JavaScript Exception";
@@ -149,8 +149,7 @@
149149

150150
// Use the same comprehensive fullMessage that the terminal uses (identical stack traces)
151151
std::string completeStackTrace = reasonStr ? [reasonStr UTF8String] : fullMessage;
152-
NSLog(@"***** End stack trace - showing beautiful NativeScript error modal and continuing "
153-
@"execution *****\n");
152+
NSLog(@"***** End stack trace - Fix error to continue *****\n");
154153
ShowErrorModal(errorTitle, errorMessage, completeStackTrace);
155154

156155
// Don't crash in debug mode - just return
@@ -557,15 +556,15 @@
557556
@try {
558557
NativeScriptException::showErrorModalSynchronously(title, message, stackTrace);
559558
} @catch (NSException* exception) {
560-
NSLog(@"Failed to create error modal UI: %@", exception);
559+
// NSLog(@"Failed to create error modal UI: %@", exception);
561560
NSLog(@"Error details - Title: %s, Message: %s", title.c_str(), message.c_str());
562561
}
563562
} else {
564563
dispatch_sync(dispatch_get_main_queue(), ^{
565564
@try {
566565
NativeScriptException::showErrorModalSynchronously(title, message, stackTrace);
567566
} @catch (NSException* exception) {
568-
NSLog(@"Failed to create error modal UI: %@", exception);
567+
// NSLog(@"Failed to create error modal UI: %@", exception);
569568
NSLog(@"Error details - Title: %s, Message: %s", title.c_str(), message.c_str());
570569
}
571570
});
@@ -575,8 +574,6 @@
575574
void NativeScriptException::showErrorModalSynchronously(const std::string& title,
576575
const std::string& message,
577576
const std::string& stackTrace) {
578-
NSLog(@"🎨 Creating beautiful error modal UI...");
579-
580577
// Use static variables to keep strong references and prevent deallocation
581578
static UIWindow* __attribute__((unused)) foundationWindowRef =
582579
nil; // Keep foundation window alive
@@ -585,19 +582,10 @@
585582
// BOOTSTRAP iOS APP LIFECYCLE: Ensure basic app infrastructure exists
586583
// This is crucial when JavaScript fails before UIApplicationMain completes normal setup
587584
UIApplication* sharedApp = [UIApplication sharedApplication];
588-
NSLog(@"πŸš€ Bootstrap: Current app state: %ld", (long)sharedApp.applicationState);
589-
NSLog(@"πŸš€ Bootstrap: Connected scenes: %lu", (unsigned long)sharedApp.connectedScenes.count);
590-
NSLog(@"πŸš€ Bootstrap: App windows: %lu", (unsigned long)sharedApp.windows.count);
591-
NSLog(@"πŸš€ Bootstrap: App delegate: %@", sharedApp.delegate);
592-
NSLog(@"πŸš€ Bootstrap: App delegate class: %@",
593-
sharedApp.delegate ? NSStringFromClass([sharedApp.delegate class]) : @"NULL");
594-
NSLog(@"πŸš€ Bootstrap: Main screen: %@", [UIScreen mainScreen]);
595-
NSLog(@"πŸš€ Bootstrap: Main screen bounds: %@", NSStringFromCGRect([UIScreen mainScreen].bounds));
596-
NSLog(@"πŸš€ Bootstrap: Main screen scale: %.2f", [UIScreen mainScreen].scale);
597585

598586
// If no windows exist, create a foundational window to establish the hierarchy
599587
if (sharedApp.windows.count == 0) {
600-
NSLog(@"πŸš€ Bootstrap: No app windows exist - creating foundational window hierarchy");
588+
// NSLog(@"πŸš€ Bootstrap: No app windows exist - creating foundational window hierarchy");
601589

602590
// Create a basic foundational window that mimics what UIApplicationMain would create
603591
UIWindow* foundationWindow = nil;
@@ -610,23 +598,23 @@
610598
for (UIScene* scene in sharedApp.connectedScenes) {
611599
if ([scene isKindOfClass:[UIWindowScene class]]) {
612600
foundationScene = (UIWindowScene*)scene;
613-
NSLog(@"πŸš€ Bootstrap: Found existing scene for foundation window");
601+
// NSLog(@"πŸš€ Bootstrap: Found existing scene for foundation window");
614602
break;
615603
}
616604
}
617605

618606
if (foundationScene) {
619607
foundationWindow = [[UIWindow alloc] initWithWindowScene:foundationScene];
620-
NSLog(@"πŸš€ Bootstrap: Created foundation window with existing scene");
608+
// NSLog(@"πŸš€ Bootstrap: Created foundation window with existing scene");
621609
} else {
622610
// If no scenes exist, create a window without scene (iOS 12 style fallback)
623611
foundationWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
624-
NSLog(@"πŸš€ Bootstrap: Created foundation window without scene (emergency mode)");
612+
// NSLog(@"πŸš€ Bootstrap: Created foundation window without scene (emergency mode)");
625613
}
626614
} else {
627615
// iOS 12 and below - simple window creation
628616
foundationWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
629-
NSLog(@"πŸš€ Bootstrap: Created foundation window for iOS 12");
617+
// NSLog(@"πŸš€ Bootstrap: Created foundation window for iOS 12");
630618
}
631619

632620
if (foundationWindow) {
@@ -643,57 +631,57 @@
643631
// Keep a strong reference to prevent deallocation
644632
foundationWindowRef = foundationWindow;
645633

646-
NSLog(@"πŸš€ Bootstrap: Foundation window established - app now has basic window hierarchy");
647-
NSLog(@"πŸš€ Bootstrap: Foundation window frame: %@",
648-
NSStringFromCGRect(foundationWindow.frame));
649-
NSLog(@"πŸš€ Bootstrap: Foundation window isKeyWindow: %@",
650-
foundationWindow.isKeyWindow ? @"YES" : @"NO");
651-
NSLog(@"πŸš€ Bootstrap: Foundation window hidden: %@", foundationWindow.hidden ? @"YES" : @"NO");
652-
NSLog(@"πŸš€ Bootstrap: Foundation window alpha: %.2f", foundationWindow.alpha);
653-
NSLog(@"πŸš€ Bootstrap: Foundation window level: %.0f", foundationWindow.windowLevel);
654-
NSLog(@"πŸš€ Bootstrap: Foundation window rootViewController: %@",
655-
foundationWindow.rootViewController);
634+
// NSLog(@"πŸš€ Bootstrap: Foundation window established - app now has basic window hierarchy");
635+
// NSLog(@"πŸš€ Bootstrap: Foundation window frame: %@",
636+
// NSStringFromCGRect(foundationWindow.frame));
637+
// NSLog(@"πŸš€ Bootstrap: Foundation window isKeyWindow: %@",
638+
// foundationWindow.isKeyWindow ? @"YES" : @"NO");
639+
// NSLog(@"πŸš€ Bootstrap: Foundation window hidden: %@", foundationWindow.hidden ? @"YES" :
640+
// @"NO"); NSLog(@"πŸš€ Bootstrap: Foundation window alpha: %.2f", foundationWindow.alpha);
641+
// NSLog(@"πŸš€ Bootstrap: Foundation window level: %.0f", foundationWindow.windowLevel);
642+
// NSLog(@"πŸš€ Bootstrap: Foundation window rootViewController: %@",
643+
// foundationWindow.rootViewController);
656644

657645
// Give iOS a moment to process the new window hierarchy (we're already on main queue)
658646
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.01, false);
659647

660648
// Check again after run loop processing
661-
NSLog(@"πŸš€ Bootstrap: App windows after bootstrap: %lu",
662-
(unsigned long)sharedApp.windows.count);
663-
NSLog(@"πŸš€ Bootstrap: Foundation window still exists: %@", foundationWindow ? @"YES" : @"NO");
664-
NSLog(@"πŸš€ Bootstrap: Foundation window ref still exists: %@",
665-
foundationWindowRef ? @"YES" : @"NO");
649+
// NSLog(@"πŸš€ Bootstrap: App windows after bootstrap: %lu",
650+
// (unsigned long)sharedApp.windows.count);
651+
// NSLog(@"πŸš€ Bootstrap: Foundation window still exists: %@", foundationWindow ? @"YES" :
652+
// @"NO"); NSLog(@"πŸš€ Bootstrap: Foundation window ref still exists: %@",
653+
// foundationWindowRef ? @"YES" : @"NO");
666654

667655
// Detailed window hierarchy inspection
668656
if (sharedApp.windows.count > 0) {
669-
NSLog(@"πŸš€ Bootstrap: Window hierarchy details:");
670-
for (NSUInteger i = 0; i < sharedApp.windows.count; i++) {
671-
UIWindow* window = sharedApp.windows[i];
672-
NSLog(@"πŸš€ Bootstrap: Window %lu: %@ (level: %.0f, key: %@, hidden: %@)", i, window,
673-
window.windowLevel, window.isKeyWindow ? @"YES" : @"NO",
674-
window.hidden ? @"YES" : @"NO");
675-
}
657+
// NSLog(@"πŸš€ Bootstrap: Window hierarchy details:");
658+
// for (NSUInteger i = 0; i < sharedApp.windows.count; i++) {
659+
// UIWindow* window = sharedApp.windows[i];
660+
// NSLog(@"πŸš€ Bootstrap: Window %lu: %@ (level: %.0f, key: %@, hidden: %@)", i, window,
661+
// window.windowLevel, window.isKeyWindow ? @"YES" : @"NO",
662+
// window.hidden ? @"YES" : @"NO");
663+
// }
676664
} else {
677-
NSLog(@"πŸš€ Bootstrap: 🚨 CRITICAL: Foundation window not in app.windows hierarchy!");
678-
NSLog(@"πŸš€ Bootstrap: This indicates a fundamental iOS window system issue");
665+
// NSLog(@"πŸš€ Bootstrap: 🚨 CRITICAL: Foundation window not in app.windows hierarchy!");
666+
// NSLog(@"πŸš€ Bootstrap: This indicates a fundamental iOS window system issue");
679667

680668
// Try alternative window registration approach
681-
NSLog(@"πŸš€ Bootstrap: Attempting alternative window registration...");
669+
// NSLog(@"πŸš€ Bootstrap: Attempting alternative window registration...");
682670
[foundationWindow.layer setNeedsDisplay];
683671
[foundationWindow.layer displayIfNeeded];
684672
[foundationWindow layoutIfNeeded];
685673

686674
// Force another run loop cycle
687675
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.05, false);
688-
NSLog(@"πŸš€ Bootstrap: After alternative registration - App windows: %lu",
689-
(unsigned long)sharedApp.windows.count);
676+
// NSLog(@"πŸš€ Bootstrap: After alternative registration - App windows: %lu",
677+
// (unsigned long)sharedApp.windows.count);
690678
}
691679
} else {
692-
NSLog(@"πŸš€ Bootstrap: WARNING - Failed to create foundation window");
680+
// NSLog(@"πŸš€ Bootstrap: WARNING - Failed to create foundation window");
693681
}
694682
} else {
695-
NSLog(@"πŸš€ Bootstrap: App windows already exist (%lu) - no bootstrap needed",
696-
(unsigned long)sharedApp.windows.count);
683+
// NSLog(@"πŸš€ Bootstrap: App windows already exist (%lu) - no bootstrap needed",
684+
// (unsigned long)sharedApp.windows.count);
697685
}
698686

699687
// Create a dedicated error window that works even during early app lifecycle
@@ -714,23 +702,23 @@
714702
for (UIScene* scene in [UIApplication sharedApplication].connectedScenes) {
715703
if ([scene isKindOfClass:[UIWindowScene class]]) {
716704
windowScene = (UIWindowScene*)scene;
717-
NSLog(@"🎨 Found existing window scene for error modal");
705+
// NSLog(@"🎨 Found existing window scene for error modal");
718706
break;
719707
}
720708
}
721709

722710
if (windowScene) {
723711
errorWindow = [[UIWindow alloc] initWithWindowScene:windowScene];
724-
NSLog(@"🎨 Created error window with existing scene");
712+
// NSLog(@"🎨 Created error window with existing scene");
725713
} else {
726714
// Fallback: create window with screen bounds (older behavior)
727715
errorWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
728-
NSLog(@"🎨 Created error window with screen bounds (no scene available)");
716+
// NSLog(@"🎨 Created error window with screen bounds (no scene available)");
729717
}
730718
} else {
731719
// iOS 12 and below
732720
errorWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
733-
NSLog(@"🎨 Created error window for iOS 12");
721+
// NSLog(@"🎨 Created error window for iOS 12");
734722
}
735723

736724
errorWindow.windowLevel = UIWindowLevelAlert + 1000; // Above everything
@@ -774,13 +762,13 @@
774762
if (logoImage) {
775763
dispatch_async(dispatch_get_main_queue(), ^{
776764
logoImageView.image = logoImage;
777-
NSLog(@"🎨 NativeScript logo loaded successfully");
765+
// NSLog(@"🎨 NativeScript logo loaded successfully");
778766
});
779767
} else {
780-
NSLog(@"🎨 Failed to create image from logo data");
768+
// NSLog(@"🎨 Failed to create image from logo data");
781769
}
782770
} else {
783-
NSLog(@"🎨 Failed to load NativeScript logo: %@", error.localizedDescription);
771+
// NSLog(@"🎨 Failed to load NativeScript logo: %@", error.localizedDescription);
784772
// Fallback: show text logo
785773
dispatch_async(dispatch_get_main_queue(), ^{
786774
UILabel* fallbackLogo = [[UILabel alloc] init];
@@ -834,7 +822,7 @@
834822
stackTraceContainer.translatesAutoresizingMaskIntoConstraints = NO;
835823
[contentView addSubview:stackTraceContainer];
836824

837-
NSLog(@"errorToDisplay from in NativeScriptException ShowErrorModal: %s", stackTrace.c_str());
825+
// NSLog(@"errorToDisplay from in NativeScriptException ShowErrorModal: %s", stackTrace.c_str());
838826
// Stack trace text view - with proper terminal styling
839827
UITextView* stackTraceTextView = [[UITextView alloc] init];
840828
stackTraceTextView.text = [NSString stringWithUTF8String:stackTrace.c_str()];
@@ -1084,12 +1072,12 @@
10841072
errorWindow.rootViewController = errorViewController;
10851073

10861074
// Force the window to be visible with multiple approaches
1087-
NSLog(@"🎨 Attempting to display error modal...");
1075+
// NSLog(@"🎨 Attempting to display error modal...");
10881076

10891077
@try {
10901078
// Primary approach: makeKeyAndVisible
10911079
[errorWindow makeKeyAndVisible];
1092-
NSLog(@"🎨 makeKeyAndVisible called successfully");
1080+
// NSLog(@"🎨 makeKeyAndVisible called successfully");
10931081

10941082
// Secondary approach: force visibility
10951083
errorWindow.hidden = NO;
@@ -1102,20 +1090,20 @@
11021090
// Bring window to front (alternative to makeKeyAndVisible)
11031091
[errorWindow bringSubviewToFront:errorViewController.view];
11041092

1105-
NSLog(@"🎨 Error window properties: hidden=%@, alpha=%.2f, windowLevel=%.0f",
1106-
errorWindow.hidden ? @"YES" : @"NO", errorWindow.alpha, errorWindow.windowLevel);
1093+
// NSLog(@"🎨 Error window properties: hidden=%@, alpha=%.2f, windowLevel=%.0f",
1094+
// errorWindow.hidden ? @"YES" : @"NO", errorWindow.alpha, errorWindow.windowLevel);
11071095

1108-
NSLog(@"🎨 Error window frame: %@", NSStringFromCGRect(errorWindow.frame));
1109-
NSLog(@"🎨 Error window rootViewController: %@", errorWindow.rootViewController);
1096+
// NSLog(@"🎨 Error window frame: %@", NSStringFromCGRect(errorWindow.frame));
1097+
// NSLog(@"🎨 Error window rootViewController: %@", errorWindow.rootViewController);
11101098

11111099
// Verify the window is in the window hierarchy
11121100
NSArray* windows = [UIApplication sharedApplication].windows;
11131101
BOOL windowInHierarchy = [windows containsObject:errorWindow];
1114-
NSLog(@"🎨 Error window in app windows: %@", windowInHierarchy ? @"YES" : @"NO");
1102+
// NSLog(@"🎨 Error window in app windows: %@", windowInHierarchy ? @"YES" : @"NO");
11151103

11161104
if (!windowInHierarchy) {
1117-
NSLog(@"🎨 WARNING: Error window not found in app windows hierarchy!");
1118-
NSLog(@"🎨 FIXING: Forcing window into hierarchy using aggressive methods...");
1105+
// NSLog(@"🎨 WARNING: Error window not found in app windows hierarchy!");
1106+
// NSLog(@"🎨 FIXING: Forcing window into hierarchy using aggressive methods...");
11191107

11201108
// Aggressive fix 1: Try to force the window to be key and make it the only visible window
11211109
NSLog(@"🎨 Total app windows before fix: %lu", (unsigned long)windows.count);
@@ -1125,7 +1113,7 @@
11251113
if (window != errorWindow) {
11261114
window.hidden = YES;
11271115
window.alpha = 0.0;
1128-
NSLog(@"🎨 Hiding existing window: %@", window);
1116+
// NSLog(@"🎨 Hiding existing window: %@", window);
11291117
}
11301118
}
11311119

@@ -1148,12 +1136,12 @@
11481136
for (UIScene* scene in [UIApplication sharedApplication].connectedScenes) {
11491137
if ([scene isKindOfClass:[UIWindowScene class]]) {
11501138
UIWindowScene* windowScene = (UIWindowScene*)scene;
1151-
NSLog(@"🎨 Found scene: %@ with %lu windows", scene,
1152-
(unsigned long)windowScene.windows.count);
1139+
// NSLog(@"🎨 Found scene: %@ with %lu windows", scene,
1140+
// (unsigned long)windowScene.windows.count);
11531141

11541142
// Check if our window is in this scene
11551143
if (![windowScene.windows containsObject:errorWindow]) {
1156-
NSLog(@"🎨 Error window not in scene - this is the core issue!");
1144+
// NSLog(@"🎨 Error window not in scene - this is the core issue!");
11571145
}
11581146
break;
11591147
}
@@ -1162,7 +1150,7 @@
11621150

11631151
// SIMPLIFIED NUCLEAR OPTION: Create a basic error window that works even during boot
11641152
if (windows.count == 0) {
1165-
NSLog(@"🎨 SIMPLIFIED NUCLEAR: Creating basic error window for boot-level crash");
1153+
// NSLog(@"🎨 SIMPLIFIED NUCLEAR: Creating basic error window for boot-level crash");
11661154

11671155
// Create the simplest possible window that can display
11681156
UIWindow* simpleWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
@@ -1191,7 +1179,7 @@
11911179
// Force display with minimal complexity
11921180
[simpleWindow makeKeyAndVisible];
11931181

1194-
NSLog(@"🎨 Simple nuclear window created - should be visible immediately");
1182+
// NSLog(@"🎨 Simple nuclear window created - should be visible immediately");
11951183
} else {
11961184
UIWindow* existingWindow = windows.firstObject;
11971185

@@ -1240,15 +1228,15 @@
12401228
[existingWindow addSubview:errorOverlay];
12411229
[existingWindow bringSubviewToFront:errorOverlay];
12421230

1243-
NSLog(@"🎨 Error overlay added to existing window successfully!");
1231+
// NSLog(@"🎨 Error overlay added to existing window successfully!");
12441232
}
12451233
}
12461234

1247-
NSLog(@"🎨 Beautiful NativeScript-branded error modal displayed successfully!");
1235+
// NSLog(@"🎨 Beautiful NativeScript-branded error modal displayed successfully!");
12481236

12491237
} @catch (NSException* exception) {
1250-
NSLog(@"🎨 ERROR: Failed to display error modal: %@", exception);
1251-
NSLog(@"🎨 Attempting fallback display method...");
1238+
// NSLog(@"🎨 ERROR: Failed to display error modal: %@", exception);
1239+
// NSLog(@"🎨 Attempting fallback display method...");
12521240

12531241
// Fallback: Try to show an alert instead
12541242
UIAlertController* alert =
@@ -1272,7 +1260,8 @@
12721260
// Add a delay to ensure the UI is fully rendered and give the modal time to stabilize
12731261
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)),
12741262
dispatch_get_main_queue(), ^{
1275-
NSLog(@"🎨 Error modal UI fully rendered and stable - app should stay alive now");
1263+
// NSLog(@"🎨 Error modal UI fully rendered and stable - app should stay alive
1264+
// now");
12761265

12771266
// Force the main run loop to process any pending events to keep the app
12781267
// responsive

0 commit comments

Comments
Β (0)