@@ -133,7 +133,9 @@ void on_error(NSString* format, ...)
133
133
NSString * str = [[[NSString alloc ] initWithFormat: format arguments: valist] autorelease ];
134
134
va_end (valist);
135
135
136
- NSLog (@" [ !! ] %@ " , str);
136
+ if (!_json_output) {
137
+ NSLog (@" [ !! ] %@ " , str);
138
+ }
137
139
138
140
exit (exitcode_error);
139
141
}
@@ -556,6 +558,12 @@ void mount_developer_image(AMDeviceRef device) {
556
558
} else if (result == 0xe8000076 /* already mounted */ ) {
557
559
NSLogOut (@" [ 95%% ] Developer disk image already mounted" );
558
560
} else {
561
+ if (result == 0xe80000e2 /* device locked */ ) {
562
+ NSLogOut (@" The device is locked." );
563
+ NSLogJSON (@{@" Event" : @" Error" ,
564
+ @" Status" : @" DeviceLocked"
565
+ });
566
+ }
559
567
on_error (@" Unable to mount developer disk image. (%x )" , result);
560
568
}
561
569
@@ -572,7 +580,13 @@ mach_error_t transfer_callback(CFDictionaryRef dict, int arg) {
572
580
CFStringRef path = CFDictionaryGetValue (dict, CFSTR (" Path" ));
573
581
574
582
if ((last_path == NULL || !CFEqual (path, last_path)) && !CFStringHasSuffix (path, CFSTR (" .ipa" ))) {
575
- NSLogOut (@" [%3d%% ] Copying %@ to device" , percent / 2 , path);
583
+ int overall_percent = percent / 2 ;
584
+ NSLogOut (@" [%3d%% ] Copying %@ to device" , overall_percent, path);
585
+ NSLogJSON (@{@" Event" : @" BundleCopy" ,
586
+ @" OverallPercent" : @(overall_percent),
587
+ @" Percent" : @(percent),
588
+ @" Path" : (__bridge NSString *)path
589
+ });
576
590
}
577
591
578
592
if (last_path != NULL ) {
@@ -589,7 +603,13 @@ mach_error_t install_callback(CFDictionaryRef dict, int arg) {
589
603
CFStringRef status = CFDictionaryGetValue (dict, CFSTR (" Status" ));
590
604
CFNumberGetValue (CFDictionaryGetValue (dict, CFSTR (" PercentComplete" )), kCFNumberSInt32Type , &percent);
591
605
592
- NSLogOut (@" [%3d%% ] %@ " , (percent / 2 ) + 50, status);
606
+ int overall_percent = (percent / 2 ) + 50 ;
607
+ NSLogOut (@" [%3d%% ] %@ " , overall_percent, status);
608
+ NSLogJSON (@{@" Event" : @" BundleInstall" ,
609
+ @" OverallPercent" : @(overall_percent),
610
+ @" Percent" : @(percent),
611
+ @" Status" : (__bridge NSString *)status
612
+ });
593
613
return 0 ;
594
614
}
595
615
@@ -1113,6 +1133,10 @@ void launch_debugserver_only(AMDeviceRef device, CFURLRef url)
1113
1133
1114
1134
NSLogOut (@" debugserver port: %d " , port);
1115
1135
NSLogOut (@" App path: %@ " , device_app_path);
1136
+ NSLogJSON (@{@" Event" : @" DebugServerLaunched" ,
1137
+ @" Port" : @(port),
1138
+ @" Path" : (__bridge NSString *)device_app_path
1139
+ });
1116
1140
}
1117
1141
1118
1142
CFStringRef get_bundle_id (CFURLRef app_url)
@@ -1717,6 +1741,11 @@ void handle_device(AMDeviceRef device) {
1717
1741
CFRelease (options);
1718
1742
1719
1743
NSLogOut (@" [100%% ] Installed package %@ " , [NSString stringWithUTF8String: app_path]);
1744
+ NSLogJSON (@{@" Event" : @" BundleInstall" ,
1745
+ @" OverallPercent" : @(100 ),
1746
+ @" Percent" : @(100 ),
1747
+ @" Status" : @" Complete"
1748
+ });
1720
1749
}
1721
1750
1722
1751
if (!debug)
@@ -1755,7 +1784,7 @@ void timeout_callback(CFRunLoopTimerRef timer, void *info) {
1755
1784
return ;
1756
1785
1757
1786
// App running for too long
1758
- NSLog (@" [ !! ] App is running for too long" );
1787
+ NSLogOut (@" [ !! ] App is running for too long" );
1759
1788
exit (exitcode_timeout);
1760
1789
return ;
1761
1790
} else if ((!found_device) && (!detect_only)) {
0 commit comments