rhodes 7.4.1 → 7.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. checksums.yaml +5 -5
  2. data/CREDITS +3 -1
  3. data/LICENSE +1 -1
  4. data/README.md +3 -1
  5. data/Rakefile +52 -43
  6. data/SECURITY.md +19 -0
  7. data/appveyor.yml +60 -7
  8. data/azure-pipelines.yml +67 -0
  9. data/extensions/rhoconnect-push/ext/rhoconnect-push/platform/android/src/com/rhomobile/rhoelements/ans/ANSManager.java +2 -2
  10. data/lib/commonAPI/barcode/ext/platform/android/AndroidManifest.xml +3 -1
  11. data/lib/commonAPI/barcode/ext/platform/android/src/com/google/barcodereader/BarcodeCaptureActivity.java +11 -13
  12. data/lib/commonAPI/barcode/ext/platform/android/src/com/google/barcodereader/BarcodeGraphicTracker.java +1 -1
  13. data/lib/commonAPI/barcode/ext/platform/android/src/com/google/barcodereader/ui/camera/CameraSource.java +3 -3
  14. data/lib/commonAPI/barcode/ext/platform/android/src/com/google/barcodereader/ui/camera/CameraSourcePreview.java +1 -1
  15. data/lib/commonAPI/barcode/ext.yml +4 -8
  16. data/lib/commonAPI/coreapi/ext/platform/android/Rakefile +0 -12
  17. data/lib/commonAPI/coreapi/ext/platform/android/src/com/rho/notification/Notification.java +4 -2
  18. data/lib/commonAPI/coreapi/ext/platform/android/src/com/rho/notification/NotificationScheduler.java +3 -3
  19. data/lib/commonAPI/coreapi/ext/platform/android/src/com/rho/notification/NotificationSingleton.java +1 -1
  20. data/lib/commonAPI/coreapi/ext/push.xml +5 -2
  21. data/lib/commonAPI/mediacapture/ext/camera.xml +4 -9
  22. data/lib/commonAPI/mediacapture/ext/platform/android/ApplicationFileProvider.erb +1 -1
  23. data/lib/commonAPI/mediacapture/ext/platform/android/ext_java.files +1 -9
  24. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraExtension.java +0 -2
  25. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraFactory.java +19 -24
  26. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraObject.java +317 -729
  27. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraRhoListener.java +240 -434
  28. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/{CameraSingletonObject.java → CameraSingleton.java} +68 -74
  29. data/lib/commonAPI/printing_zebra/ext/platform/android/src/com/rhomobile/printing/zebra/impl/ZebraPrintingProviderImpl.java +2 -1
  30. data/lib/extensions/fcm-push/ext/android/ApplicationManifestAdds.erb +15 -17
  31. data/lib/extensions/fcm-push/ext/android/Rakefile +59 -34
  32. data/lib/extensions/fcm-push/ext/android/ext_java.files +0 -1
  33. data/lib/extensions/fcm-push/ext/android/src/com/rhomobile/rhodes/fcm/FCMFacade.java +13 -17
  34. data/lib/extensions/fcm-push/ext/android/src/com/rhomobile/rhodes/fcm/FCMIntentService.java +81 -80
  35. data/lib/extensions/fcm-push/ext/android/src/com/rhomobile/rhodes/fcm/FCMListener.java +0 -16
  36. data/lib/extensions/fcm-push/ext.yml +1 -1
  37. data/lib/extensions/gmaps/ext/platform/android/ApplicationManifestAdds.erb +1 -0
  38. data/lib/extensions/gmaps/ext/platform/android/src/com/rhomobile/rhodes/gmaps/GMapActivity.java +12 -4
  39. data/lib/extensions/gmaps/ext.yml +3 -1
  40. data/platform/android/Rhodes/jni/src/MethodResultJni.cpp +4 -0
  41. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +3 -3
  42. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +3 -3
  43. data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/StatusNotification.java +1 -1
  44. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocation.java +14 -14
  45. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +18 -9
  46. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality26.java +1 -1
  47. data/platform/android/build/{aab_builder.rb → aapt2_helper.rb} +94 -37
  48. data/platform/android/build/android.rake +124 -191
  49. data/platform/android/build/android_tools.rb +9 -9
  50. data/platform/android/build/androidcommon.rb +18 -7
  51. data/platform/android/build/build_tools_finder.rb +46 -0
  52. data/platform/android/build/config.yml +5 -0
  53. data/platform/android/build/dex_builder.rb +88 -0
  54. data/platform/android/build/hostplatform.rb +9 -0
  55. data/platform/android/build/manifest_generator.rb +1 -0
  56. data/platform/android/build/maven_deps_extractor.rb +22 -21
  57. data/platform/android/build/ndkwrapper.rb +80 -51
  58. data/platform/iphone/Classes/AppManager/AppManager.m +3 -1
  59. data/platform/iphone/Classes/Camera/PickImageDelegate.h +2 -0
  60. data/platform/iphone/Classes/Camera/PickImageDelegate.m +45 -23
  61. data/platform/iphone/Classes/CocoaServer/CCocoaServer.h +27 -0
  62. data/platform/iphone/Classes/CocoaServer/CCocoaServer.m +107 -0
  63. data/platform/iphone/Classes/CocoaServer/RhoHTTPConnection.h +16 -0
  64. data/platform/iphone/Classes/CocoaServer/RhoHTTPConnection.m +226 -0
  65. data/platform/iphone/Classes/RhoWKWebView.mm +78 -11
  66. data/platform/iphone/Classes/RhoWebViewFabrique.m +6 -1
  67. data/platform/iphone/Classes/Rhodes.m +3 -0
  68. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDData.h +14 -0
  69. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDData.m +158 -0
  70. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDNumber.h +12 -0
  71. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDNumber.m +88 -0
  72. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDRange.h +56 -0
  73. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDRange.m +104 -0
  74. data/platform/iphone/CocoaHTTPServer/Core/HTTPAuthenticationRequest.h +45 -0
  75. data/platform/iphone/CocoaHTTPServer/Core/HTTPAuthenticationRequest.m +195 -0
  76. data/platform/iphone/CocoaHTTPServer/Core/HTTPConnection.h +120 -0
  77. data/platform/iphone/CocoaHTTPServer/Core/HTTPConnection.m +2708 -0
  78. data/platform/iphone/CocoaHTTPServer/Core/HTTPLogging.h +136 -0
  79. data/platform/iphone/CocoaHTTPServer/Core/HTTPMessage.h +48 -0
  80. data/platform/iphone/CocoaHTTPServer/Core/HTTPMessage.m +113 -0
  81. data/platform/iphone/CocoaHTTPServer/Core/HTTPResponse.h +149 -0
  82. data/platform/iphone/CocoaHTTPServer/Core/HTTPServer.h +205 -0
  83. data/platform/iphone/CocoaHTTPServer/Core/HTTPServer.m +772 -0
  84. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartFormDataParser.h +65 -0
  85. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartFormDataParser.m +529 -0
  86. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartMessageHeader.h +33 -0
  87. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartMessageHeader.m +86 -0
  88. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartMessageHeaderField.h +23 -0
  89. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartMessageHeaderField.m +211 -0
  90. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPAsyncFileResponse.h +75 -0
  91. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPAsyncFileResponse.m +405 -0
  92. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPDataResponse.h +13 -0
  93. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPDataResponse.m +79 -0
  94. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPDynamicFileResponse.h +52 -0
  95. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPDynamicFileResponse.m +292 -0
  96. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPErrorResponse.h +9 -0
  97. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPErrorResponse.m +38 -0
  98. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPFileResponse.h +25 -0
  99. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPFileResponse.m +237 -0
  100. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPRedirectResponse.h +12 -0
  101. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPRedirectResponse.m +73 -0
  102. data/platform/iphone/CocoaHTTPServer/Core/WebSocket.h +105 -0
  103. data/platform/iphone/CocoaHTTPServer/Core/WebSocket.m +791 -0
  104. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DAVConnection.h +7 -0
  105. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DAVConnection.m +160 -0
  106. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DAVResponse.h +11 -0
  107. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DAVResponse.m +372 -0
  108. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DELETEResponse.h +7 -0
  109. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DELETEResponse.m +49 -0
  110. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/PUTResponse.h +8 -0
  111. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/PUTResponse.m +69 -0
  112. data/platform/iphone/CocoaHTTPServer/LICENSE.txt +18 -0
  113. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaAsyncSocket/About.txt +4 -0
  114. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaAsyncSocket/GCDAsyncSocket.h +1226 -0
  115. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaAsyncSocket/GCDAsyncSocket.m +8528 -0
  116. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/About.txt +33 -0
  117. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDASLLogger.h +41 -0
  118. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDASLLogger.m +99 -0
  119. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
  120. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDAbstractDatabaseLogger.m +727 -0
  121. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDFileLogger.h +334 -0
  122. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDFileLogger.m +1353 -0
  123. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDLog.h +601 -0
  124. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDLog.m +1083 -0
  125. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDTTYLogger.h +167 -0
  126. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDTTYLogger.m +1479 -0
  127. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/ContextFilterLogFormatter.h +65 -0
  128. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/ContextFilterLogFormatter.m +191 -0
  129. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/DispatchQueueLogFormatter.h +116 -0
  130. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/DispatchQueueLogFormatter.m +251 -0
  131. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/README.txt +7 -0
  132. data/platform/iphone/Framework/Rhodes/Rhodes.xcodeproj/project.pbxproj +1 -1
  133. data/platform/iphone/RhoAppBaseLib/RhoAppBaseLib.xcodeproj/project.pbxproj +364 -0
  134. data/platform/iphone/rbuild/iphone.rake +4 -0
  135. data/platform/osx/bin/RhoSimulator/RhoSimulator.app.zip +0 -0
  136. data/platform/shared/common/RhodesApp.cpp +26 -1
  137. data/platform/shared/net/HttpServer.cpp +20 -0
  138. data/platform/shared/qt/RhoSimulator.pro +1 -1
  139. data/platform/shared/ruby/osx/ruby/config.h +2 -0
  140. data/platform/shared/ruby/win32/win32.c +10 -3
  141. data/platform/win32/RhoSimulator/RhoSimulator.exe +0 -0
  142. data/rakefile.rb +52 -43
  143. data/res/build-tools/RhoRuby.exe +0 -0
  144. data/res/build-tools/aapt2/linux/aapt2 +0 -0
  145. data/res/build-tools/aapt2/osx/aapt2 +0 -0
  146. data/res/generators/templates/application/AndroidManifest.erb +2 -1
  147. data/res/generators/templates/application/build.yml +4 -1
  148. data/res/generators/templates/application/rhoconfig.txt +5 -0
  149. data/rhobuild.yml.example +4 -4
  150. data/rhodes.gemspec +1 -2
  151. data/version +1 -1
  152. metadata +80 -35
  153. data/lib/commonAPI/mediacapture/ext/platform/android/adds/res/drawable/camera_btn.xml +0 -14
  154. data/lib/commonAPI/mediacapture/ext/platform/android/adds/res/layout/camera_land.xml +0 -23
  155. data/lib/commonAPI/mediacapture/ext/platform/android/adds/res/layout/camera_port.xml +0 -23
  156. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraActivity.java +0 -156
  157. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraEclair.java +0 -227
  158. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraGingerbread.java +0 -152
  159. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraPreview.java +0 -183
  160. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraSingletonEclair.java +0 -14
  161. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraSingletonGingerbread.java +0 -60
  162. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/ICameraObject.java +0 -20
  163. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/ICameraSingletonObject.java +0 -8
  164. data/lib/extensions/fcm-push/ext/android/src/com/rhomobile/rhodes/fcm/FCMTokenRefresherService.java +0 -27
  165. data/platform/android/Rhodes/AndroidManifest.xml.erb +0 -89
@@ -0,0 +1,65 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import "DDLog.h"
3
+
4
+ @class ContextFilterLogFormatter;
5
+
6
+ /**
7
+ * Welcome to Cocoa Lumberjack!
8
+ *
9
+ * The project page has a wealth of documentation if you have any questions.
10
+ * https://github.com/robbiehanson/CocoaLumberjack
11
+ *
12
+ * If you're new to the project you may wish to read the "Getting Started" page.
13
+ * https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted
14
+ *
15
+ *
16
+ * This class provides a log formatter that filters log statements from a logging context not on the whitelist.
17
+ *
18
+ * A log formatter can be added to any logger to format and/or filter its output.
19
+ * You can learn more about log formatters here:
20
+ * https://github.com/robbiehanson/CocoaLumberjack/wiki/CustomFormatters
21
+ *
22
+ * You can learn more about logging context's here:
23
+ * https://github.com/robbiehanson/CocoaLumberjack/wiki/CustomContext
24
+ *
25
+ * But here's a quick overview / refresher:
26
+ *
27
+ * Every log statement has a logging context.
28
+ * These come from the underlying logging macros defined in DDLog.h.
29
+ * The default logging context is zero.
30
+ * You can define multiple logging context's for use in your application.
31
+ * For example, logically separate parts of your app each have a different logging context.
32
+ * Also 3rd party frameworks that make use of Lumberjack generally use their own dedicated logging context.
33
+ **/
34
+ @interface ContextWhitelistFilterLogFormatter : NSObject <DDLogFormatter>
35
+
36
+ - (id)init;
37
+
38
+ - (void)addToWhitelist:(int)loggingContext;
39
+ - (void)removeFromWhitelist:(int)loggingContext;
40
+
41
+ - (NSArray *)whitelist;
42
+
43
+ - (BOOL)isOnWhitelist:(int)loggingContext;
44
+
45
+ @end
46
+
47
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
48
+ #pragma mark -
49
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
50
+
51
+ /**
52
+ * This class provides a log formatter that filters log statements from a logging context on the blacklist.
53
+ **/
54
+ @interface ContextBlacklistFilterLogFormatter : NSObject <DDLogFormatter>
55
+
56
+ - (id)init;
57
+
58
+ - (void)addToBlacklist:(int)loggingContext;
59
+ - (void)removeFromBlacklist:(int)loggingContext;
60
+
61
+ - (NSArray *)blacklist;
62
+
63
+ - (BOOL)isOnBlacklist:(int)loggingContext;
64
+
65
+ @end
@@ -0,0 +1,191 @@
1
+ #import "ContextFilterLogFormatter.h"
2
+ #import <libkern/OSAtomic.h>
3
+
4
+ /**
5
+ * Welcome to Cocoa Lumberjack!
6
+ *
7
+ * The project page has a wealth of documentation if you have any questions.
8
+ * https://github.com/robbiehanson/CocoaLumberjack
9
+ *
10
+ * If you're new to the project you may wish to read the "Getting Started" wiki.
11
+ * https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted
12
+ **/
13
+
14
+ #if ! __has_feature(objc_arc)
15
+ #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
16
+ #endif
17
+
18
+ @interface LoggingContextSet : NSObject
19
+
20
+ - (void)addToSet:(int)loggingContext;
21
+ - (void)removeFromSet:(int)loggingContext;
22
+
23
+ - (NSArray *)currentSet;
24
+
25
+ - (BOOL)isInSet:(int)loggingContext;
26
+
27
+ @end
28
+
29
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
30
+ #pragma mark -
31
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
32
+
33
+ @implementation ContextWhitelistFilterLogFormatter
34
+ {
35
+ LoggingContextSet *contextSet;
36
+ }
37
+
38
+ - (id)init
39
+ {
40
+ if ((self = [super init]))
41
+ {
42
+ contextSet = [[LoggingContextSet alloc] init];
43
+ }
44
+ return self;
45
+ }
46
+
47
+
48
+ - (void)addToWhitelist:(int)loggingContext
49
+ {
50
+ [contextSet addToSet:loggingContext];
51
+ }
52
+
53
+ - (void)removeFromWhitelist:(int)loggingContext
54
+ {
55
+ [contextSet removeFromSet:loggingContext];
56
+ }
57
+
58
+ - (NSArray *)whitelist
59
+ {
60
+ return [contextSet currentSet];
61
+ }
62
+
63
+ - (BOOL)isOnWhitelist:(int)loggingContext
64
+ {
65
+ return [contextSet isInSet:loggingContext];
66
+ }
67
+
68
+ - (NSString *)formatLogMessage:(DDLogMessage *)logMessage
69
+ {
70
+ if ([self isOnWhitelist:logMessage->logContext])
71
+ return logMessage->logMsg;
72
+ else
73
+ return nil;
74
+ }
75
+
76
+ @end
77
+
78
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
79
+ #pragma mark -
80
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
81
+
82
+ @implementation ContextBlacklistFilterLogFormatter
83
+ {
84
+ LoggingContextSet *contextSet;
85
+ }
86
+
87
+ - (id)init
88
+ {
89
+ if ((self = [super init]))
90
+ {
91
+ contextSet = [[LoggingContextSet alloc] init];
92
+ }
93
+ return self;
94
+ }
95
+
96
+
97
+ - (void)addToBlacklist:(int)loggingContext
98
+ {
99
+ [contextSet addToSet:loggingContext];
100
+ }
101
+
102
+ - (void)removeFromBlacklist:(int)loggingContext
103
+ {
104
+ [contextSet removeFromSet:loggingContext];
105
+ }
106
+
107
+ - (NSArray *)blacklist
108
+ {
109
+ return [contextSet currentSet];
110
+ }
111
+
112
+ - (BOOL)isOnBlacklist:(int)loggingContext
113
+ {
114
+ return [contextSet isInSet:loggingContext];
115
+ }
116
+
117
+ - (NSString *)formatLogMessage:(DDLogMessage *)logMessage
118
+ {
119
+ if ([self isOnBlacklist:logMessage->logContext])
120
+ return nil;
121
+ else
122
+ return logMessage->logMsg;
123
+ }
124
+
125
+ @end
126
+
127
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
128
+ #pragma mark -
129
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
130
+
131
+ @implementation LoggingContextSet
132
+ {
133
+ OSSpinLock lock;
134
+ NSMutableSet *set;
135
+ }
136
+
137
+ - (id)init
138
+ {
139
+ if ((self = [super init]))
140
+ {
141
+ set = [[NSMutableSet alloc] init];
142
+ }
143
+ return self;
144
+ }
145
+
146
+
147
+ - (void)addToSet:(int)loggingContext
148
+ {
149
+ OSSpinLockLock(&lock);
150
+ {
151
+ [set addObject:@(loggingContext)];
152
+ }
153
+ OSSpinLockUnlock(&lock);
154
+ }
155
+
156
+ - (void)removeFromSet:(int)loggingContext
157
+ {
158
+ OSSpinLockLock(&lock);
159
+ {
160
+ [set removeObject:@(loggingContext)];
161
+ }
162
+ OSSpinLockUnlock(&lock);
163
+ }
164
+
165
+ - (NSArray *)currentSet
166
+ {
167
+ NSArray *result = nil;
168
+
169
+ OSSpinLockLock(&lock);
170
+ {
171
+ result = [set allObjects];
172
+ }
173
+ OSSpinLockUnlock(&lock);
174
+
175
+ return result;
176
+ }
177
+
178
+ - (BOOL)isInSet:(int)loggingContext
179
+ {
180
+ BOOL result = NO;
181
+
182
+ OSSpinLockLock(&lock);
183
+ {
184
+ result = [set containsObject:@(loggingContext)];
185
+ }
186
+ OSSpinLockUnlock(&lock);
187
+
188
+ return result;
189
+ }
190
+
191
+ @end
@@ -0,0 +1,116 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <libkern/OSAtomic.h>
3
+ #import "DDLog.h"
4
+
5
+
6
+ /**
7
+ * Welcome to Cocoa Lumberjack!
8
+ *
9
+ * The project page has a wealth of documentation if you have any questions.
10
+ * https://github.com/robbiehanson/CocoaLumberjack
11
+ *
12
+ * If you're new to the project you may wish to read the "Getting Started" page.
13
+ * https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted
14
+ *
15
+ *
16
+ * This class provides a log formatter that prints the dispatch_queue label instead of the mach_thread_id.
17
+ *
18
+ * A log formatter can be added to any logger to format and/or filter its output.
19
+ * You can learn more about log formatters here:
20
+ * https://github.com/robbiehanson/CocoaLumberjack/wiki/CustomFormatters
21
+ *
22
+ * A typical NSLog (or DDTTYLogger) prints detailed info as [<process_id>:<thread_id>].
23
+ * For example:
24
+ *
25
+ * 2011-10-17 20:21:45.435 AppName[19928:5207] Your log message here
26
+ *
27
+ * Where:
28
+ * - 19928 = process id
29
+ * - 5207 = thread id (mach_thread_id printed in hex)
30
+ *
31
+ * When using grand central dispatch (GCD), this information is less useful.
32
+ * This is because a single serial dispatch queue may be run on any thread from an internally managed thread pool.
33
+ * For example:
34
+ *
35
+ * 2011-10-17 20:32:31.111 AppName[19954:4d07] Message from my_serial_dispatch_queue
36
+ * 2011-10-17 20:32:31.112 AppName[19954:5207] Message from my_serial_dispatch_queue
37
+ * 2011-10-17 20:32:31.113 AppName[19954:2c55] Message from my_serial_dispatch_queue
38
+ *
39
+ * This formatter allows you to replace the standard [box:info] with the dispatch_queue name.
40
+ * For example:
41
+ *
42
+ * 2011-10-17 20:32:31.111 AppName[img-scaling] Message from my_serial_dispatch_queue
43
+ * 2011-10-17 20:32:31.112 AppName[img-scaling] Message from my_serial_dispatch_queue
44
+ * 2011-10-17 20:32:31.113 AppName[img-scaling] Message from my_serial_dispatch_queue
45
+ *
46
+ * If the dispatch_queue doesn't have a set name, then it falls back to the thread name.
47
+ * If the current thread doesn't have a set name, then it falls back to the mach_thread_id in hex (like normal).
48
+ *
49
+ * Note: If manually creating your own background threads (via NSThread/alloc/init or NSThread/detachNeThread),
50
+ * you can use [[NSThread currentThread] setName:(NSString *)].
51
+ **/
52
+ @interface DispatchQueueLogFormatter : NSObject <DDLogFormatter> {
53
+ @protected
54
+
55
+ NSString *dateFormatString;
56
+ }
57
+
58
+ /**
59
+ * Standard init method.
60
+ * Configure using properties as desired.
61
+ **/
62
+ - (id)init;
63
+
64
+ /**
65
+ * The minQueueLength restricts the minimum size of the [detail box].
66
+ * If the minQueueLength is set to 0, there is no restriction.
67
+ *
68
+ * For example, say a dispatch_queue has a label of "diskIO":
69
+ *
70
+ * If the minQueueLength is 0: [diskIO]
71
+ * If the minQueueLength is 4: [diskIO]
72
+ * If the minQueueLength is 5: [diskIO]
73
+ * If the minQueueLength is 6: [diskIO]
74
+ * If the minQueueLength is 7: [diskIO ]
75
+ * If the minQueueLength is 8: [diskIO ]
76
+ *
77
+ * The default minQueueLength is 0 (no minimum, so [detail box] won't be padded).
78
+ *
79
+ * If you want every [detail box] to have the exact same width,
80
+ * set both minQueueLength and maxQueueLength to the same value.
81
+ **/
82
+ @property (assign) NSUInteger minQueueLength;
83
+
84
+ /**
85
+ * The maxQueueLength restricts the number of characters that will be inside the [detail box].
86
+ * If the maxQueueLength is 0, there is no restriction.
87
+ *
88
+ * For example, say a dispatch_queue has a label of "diskIO":
89
+ *
90
+ * If the maxQueueLength is 0: [diskIO]
91
+ * If the maxQueueLength is 4: [disk]
92
+ * If the maxQueueLength is 5: [diskI]
93
+ * If the maxQueueLength is 6: [diskIO]
94
+ * If the maxQueueLength is 7: [diskIO]
95
+ * If the maxQueueLength is 8: [diskIO]
96
+ *
97
+ * The default maxQueueLength is 0 (no maximum, so [detail box] won't be truncated).
98
+ *
99
+ * If you want every [detail box] to have the exact same width,
100
+ * set both minQueueLength and maxQueueLength to the same value.
101
+ **/
102
+ @property (assign) NSUInteger maxQueueLength;
103
+
104
+ /**
105
+ * Sometimes queue labels have long names like "com.apple.main-queue",
106
+ * but you'd prefer something shorter like simply "main".
107
+ *
108
+ * This method allows you to set such preferred replacements.
109
+ * The above example is set by default.
110
+ *
111
+ * To remove/undo a previous replacement, invoke this method with nil for the 'shortLabel' parameter.
112
+ **/
113
+ - (NSString *)replacementStringForQueueLabel:(NSString *)longLabel;
114
+ - (void)setReplacementString:(NSString *)shortLabel forQueueLabel:(NSString *)longLabel;
115
+
116
+ @end
@@ -0,0 +1,251 @@
1
+ #import "DispatchQueueLogFormatter.h"
2
+ #import <libkern/OSAtomic.h>
3
+
4
+ /**
5
+ * Welcome to Cocoa Lumberjack!
6
+ *
7
+ * The project page has a wealth of documentation if you have any questions.
8
+ * https://github.com/robbiehanson/CocoaLumberjack
9
+ *
10
+ * If you're new to the project you may wish to read the "Getting Started" wiki.
11
+ * https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted
12
+ **/
13
+
14
+ #if ! __has_feature(objc_arc)
15
+ #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
16
+ #endif
17
+
18
+
19
+ @implementation DispatchQueueLogFormatter
20
+ {
21
+ int32_t atomicLoggerCount;
22
+ NSDateFormatter *threadUnsafeDateFormatter; // Use [self stringFromDate]
23
+
24
+ OSSpinLock lock;
25
+
26
+ NSUInteger _minQueueLength; // _prefix == Only access via atomic property
27
+ NSUInteger _maxQueueLength; // _prefix == Only access via atomic property
28
+ NSMutableDictionary *_replacements; // _prefix == Only access from within spinlock
29
+ }
30
+
31
+ - (id)init
32
+ {
33
+ if ((self = [super init]))
34
+ {
35
+ dateFormatString = @"yyyy-MM-dd HH:mm:ss:SSS";
36
+
37
+ atomicLoggerCount = 0;
38
+ threadUnsafeDateFormatter = nil;
39
+
40
+ _minQueueLength = 0;
41
+ _maxQueueLength = 0;
42
+ _replacements = [[NSMutableDictionary alloc] init];
43
+
44
+ // Set default replacements:
45
+
46
+ [_replacements setObject:@"main" forKey:@"com.apple.main-thread"];
47
+ }
48
+ return self;
49
+ }
50
+
51
+
52
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
53
+ #pragma mark Configuration
54
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
55
+
56
+ @synthesize minQueueLength = _minQueueLength;
57
+ @synthesize maxQueueLength = _maxQueueLength;
58
+
59
+ - (NSString *)replacementStringForQueueLabel:(NSString *)longLabel
60
+ {
61
+ NSString *result = nil;
62
+
63
+ OSSpinLockLock(&lock);
64
+ {
65
+ result = [_replacements objectForKey:longLabel];
66
+ }
67
+ OSSpinLockUnlock(&lock);
68
+
69
+ return result;
70
+ }
71
+
72
+ - (void)setReplacementString:(NSString *)shortLabel forQueueLabel:(NSString *)longLabel
73
+ {
74
+ OSSpinLockLock(&lock);
75
+ {
76
+ if (shortLabel)
77
+ [_replacements setObject:shortLabel forKey:longLabel];
78
+ else
79
+ [_replacements removeObjectForKey:longLabel];
80
+ }
81
+ OSSpinLockUnlock(&lock);
82
+ }
83
+
84
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
85
+ #pragma mark DDLogFormatter
86
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
87
+
88
+ - (NSString *)stringFromDate:(NSDate *)date
89
+ {
90
+ int32_t loggerCount = OSAtomicAdd32(0, &atomicLoggerCount);
91
+
92
+ if (loggerCount <= 1)
93
+ {
94
+ // Single-threaded mode.
95
+
96
+ if (threadUnsafeDateFormatter == nil)
97
+ {
98
+ threadUnsafeDateFormatter = [[NSDateFormatter alloc] init];
99
+ [threadUnsafeDateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
100
+ [threadUnsafeDateFormatter setDateFormat:dateFormatString];
101
+ }
102
+
103
+ return [threadUnsafeDateFormatter stringFromDate:date];
104
+ }
105
+ else
106
+ {
107
+ // Multi-threaded mode.
108
+ // NSDateFormatter is NOT thread-safe.
109
+
110
+ NSString *key = @"DispatchQueueLogFormatter_NSDateFormatter";
111
+
112
+ NSMutableDictionary *threadDictionary = [[NSThread currentThread] threadDictionary];
113
+ NSDateFormatter *dateFormatter = [threadDictionary objectForKey:key];
114
+
115
+ if (dateFormatter == nil)
116
+ {
117
+ dateFormatter = [[NSDateFormatter alloc] init];
118
+ [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
119
+ [dateFormatter setDateFormat:dateFormatString];
120
+
121
+ [threadDictionary setObject:dateFormatter forKey:key];
122
+ }
123
+
124
+ return [dateFormatter stringFromDate:date];
125
+ }
126
+ }
127
+
128
+ - (NSString *)queueThreadLabelForLogMessage:(DDLogMessage *)logMessage
129
+ {
130
+ // As per the DDLogFormatter contract, this method is always invoked on the same thread/dispatch_queue
131
+
132
+ NSUInteger minQueueLength = self.minQueueLength;
133
+ NSUInteger maxQueueLength = self.maxQueueLength;
134
+
135
+ // Get the name of the queue, thread, or machID (whichever we are to use).
136
+
137
+ NSString *queueThreadLabel = nil;
138
+
139
+ BOOL useQueueLabel = YES;
140
+ BOOL useThreadName = NO;
141
+
142
+ if (logMessage->queueLabel)
143
+ {
144
+ // If you manually create a thread, it's dispatch_queue will have one of the thread names below.
145
+ // Since all such threads have the same name, we'd prefer to use the threadName or the machThreadID.
146
+
147
+ char *names[] = { "com.apple.root.low-priority",
148
+ "com.apple.root.default-priority",
149
+ "com.apple.root.high-priority",
150
+ "com.apple.root.low-overcommit-priority",
151
+ "com.apple.root.default-overcommit-priority",
152
+ "com.apple.root.high-overcommit-priority" };
153
+
154
+ int length = sizeof(names) / sizeof(char *);
155
+
156
+ int i;
157
+ for (i = 0; i < length; i++)
158
+ {
159
+ if (strcmp(logMessage->queueLabel, names[i]) == 0)
160
+ {
161
+ useQueueLabel = NO;
162
+ useThreadName = [logMessage->threadName length] > 0;
163
+ break;
164
+ }
165
+ }
166
+ }
167
+ else
168
+ {
169
+ useQueueLabel = NO;
170
+ useThreadName = [logMessage->threadName length] > 0;
171
+ }
172
+
173
+ if (useQueueLabel || useThreadName)
174
+ {
175
+ NSString *fullLabel;
176
+ NSString *abrvLabel;
177
+
178
+ if (useQueueLabel)
179
+ fullLabel = @(logMessage->queueLabel);
180
+ else
181
+ fullLabel = logMessage->threadName;
182
+
183
+ OSSpinLockLock(&lock);
184
+ {
185
+ abrvLabel = [_replacements objectForKey:fullLabel];
186
+ }
187
+ OSSpinLockUnlock(&lock);
188
+
189
+ if (abrvLabel)
190
+ queueThreadLabel = abrvLabel;
191
+ else
192
+ queueThreadLabel = fullLabel;
193
+ }
194
+ else
195
+ {
196
+ queueThreadLabel = [NSString stringWithFormat:@"%x", logMessage->machThreadID];
197
+ }
198
+
199
+ // Now use the thread label in the output
200
+
201
+ NSUInteger labelLength = [queueThreadLabel length];
202
+
203
+ // labelLength > maxQueueLength : truncate
204
+ // labelLength < minQueueLength : padding
205
+ // : exact
206
+
207
+ if ((maxQueueLength > 0) && (labelLength > maxQueueLength))
208
+ {
209
+ // Truncate
210
+
211
+ return [queueThreadLabel substringToIndex:maxQueueLength];
212
+ }
213
+ else if (labelLength < minQueueLength)
214
+ {
215
+ // Padding
216
+
217
+ NSUInteger numSpaces = minQueueLength - labelLength;
218
+
219
+ char spaces[numSpaces + 1];
220
+ memset(spaces, ' ', numSpaces);
221
+ spaces[numSpaces] = '\0';
222
+
223
+ return [NSString stringWithFormat:@"%@%s", queueThreadLabel, spaces];
224
+ }
225
+ else
226
+ {
227
+ // Exact
228
+
229
+ return queueThreadLabel;
230
+ }
231
+ }
232
+
233
+ - (NSString *)formatLogMessage:(DDLogMessage *)logMessage
234
+ {
235
+ NSString *timestamp = [self stringFromDate:(logMessage->timestamp)];
236
+ NSString *queueThreadLabel = [self queueThreadLabelForLogMessage:logMessage];
237
+
238
+ return [NSString stringWithFormat:@"%@ [%@] %@", timestamp, queueThreadLabel, logMessage->logMsg];
239
+ }
240
+
241
+ - (void)didAddToLogger:(id <DDLogger>)logger
242
+ {
243
+ OSAtomicIncrement32(&atomicLoggerCount);
244
+ }
245
+
246
+ - (void)willRemoveFromLogger:(id <DDLogger>)logger
247
+ {
248
+ OSAtomicDecrement32(&atomicLoggerCount);
249
+ }
250
+
251
+ @end
@@ -0,0 +1,7 @@
1
+ This folder contains some sample formatters that may be helpful.
2
+
3
+ Feel free to change them, extend them, or use them as the basis for your own custom formatter(s).
4
+
5
+ More information about creating your own custom formatters can be found on the wiki:
6
+ https://github.com/robbiehanson/CocoaLumberjack/wiki/CustomFormatters
7
+
@@ -843,7 +843,7 @@
843
843
  );
844
844
  runOnlyForDeploymentPostprocessing = 0;
845
845
  shellPath = /bin/sh;
846
- shellScript = "FRAMEWORK_NAME=\"Rhodes\"\n\nSIMULATOR_LIBRARY_PATH=\"${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework\"\n\nDEVICE_LIBRARY_PATH=\"${BUILD_DIR}/${CONFIGURATION}-iphoneos/${FRAMEWORK_NAME}.framework\"\n\nUNIVERSAL_LIBRARY_DIR=\"${BUILD_DIR}/${CONFIGURATION}-iphoneuniversal\"\n\nFRAMEWORK=\"${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_NAME}.framework\"\n\nOUTPUT_DIR=\"./${FRAMEWORK_NAME}-Aggregated\"\n\nARCHS=\"x86_64\"\n\nXcodebuild -project ${PROJECT_NAME}.Xcodeproj -scheme ${FRAMEWORK_NAME} -sdk iphonesimulator -configuration ${CONFIGURATION} install CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphonesimulator ARCHS=\"x86_64\" OTHER_CFLAGS=\"-fembed-bitcode -DHAVE_CONFIG_H -DUSE_RHOSSL\"\n\nARCHS=\"arm64 armv7\"\n\nXcodebuild -project ${PROJECT_NAME}.Xcodeproj -scheme ${FRAMEWORK_NAME} -sdk iphoneos -configuration ${CONFIGURATION} install CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphoneos ARCHS=\"arm64 armv7\" OTHER_CFLAGS=\"-fembed-bitcode -DHAVE_CONFIG_H -DUSE_RHOSSL\"\n\n\nrm -rf \"${UNIVERSAL_LIBRARY_DIR}\"\n\nmkdir \"${UNIVERSAL_LIBRARY_DIR}\"\n\nmkdir \"${FRAMEWORK}\"\n\nrm -rf \"$OUTPUT_DIR\"\nmkdir -p \"$OUTPUT_DIR\"\n\ncp -r \"${DEVICE_LIBRARY_PATH}/.\" \"${FRAMEWORK}\"\n\n\nrm -rf \"${FRAMEWORK}/${FRAMEWORK_NAME}\"\n\nlipo \"${SIMULATOR_LIBRARY_PATH}/${FRAMEWORK_NAME}\" \"${DEVICE_LIBRARY_PATH}/${FRAMEWORK_NAME}\" -create -output \"${FRAMEWORK}/${FRAMEWORK_NAME}\"\ncp -r \"${FRAMEWORK}\" \"$OUTPUT_DIR\"\n\n";
846
+ shellScript = "FRAMEWORK_NAME=\"Rhodes\"\n\nSIMULATOR_LIBRARY_PATH=\"${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework\"\n\nDEVICE_LIBRARY_PATH=\"${BUILD_DIR}/${CONFIGURATION}-iphoneos/${FRAMEWORK_NAME}.framework\"\n\nUNIVERSAL_LIBRARY_DIR=\"${BUILD_DIR}/${CONFIGURATION}-iphoneuniversal\"\n\nFRAMEWORK=\"${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_NAME}.framework\"\n\nOUTPUT_DIR=\"./${FRAMEWORK_NAME}-Aggregated\"\n\nARCHS=\"${TAU_SIM_ARCHS}\"\n\nXcodebuild -project ${PROJECT_NAME}.Xcodeproj -scheme ${FRAMEWORK_NAME} -sdk iphonesimulator -configuration ${CONFIGURATION} install CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphonesimulator ARCHS=\"${TAU_SIM_ARCHS}\" OTHER_CFLAGS=\"-fembed-bitcode -DHAVE_CONFIG_H -DUSE_RHOSSL\"\n\nARCHS=\"${TAU_DEV_ARCHS}\"\n\nXcodebuild -project ${PROJECT_NAME}.Xcodeproj -scheme ${FRAMEWORK_NAME} -sdk iphoneos -configuration ${CONFIGURATION} install CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphoneos ARCHS=\"${TAU_DEV_ARCHS}\" OTHER_CFLAGS=\"-fembed-bitcode -DHAVE_CONFIG_H -DUSE_RHOSSL\"\n\n\nrm -rf \"${UNIVERSAL_LIBRARY_DIR}\"\n\nmkdir \"${UNIVERSAL_LIBRARY_DIR}\"\n\nmkdir \"${FRAMEWORK}\"\n\nrm -rf \"$OUTPUT_DIR\"\nmkdir -p \"$OUTPUT_DIR\"\n\ncp -r \"${DEVICE_LIBRARY_PATH}/.\" \"${FRAMEWORK}\"\n\n\nrm -rf \"${FRAMEWORK}/${FRAMEWORK_NAME}\"\n\nlipo \"${SIMULATOR_LIBRARY_PATH}/${FRAMEWORK_NAME}\" \"${DEVICE_LIBRARY_PATH}/${FRAMEWORK_NAME}\" -create -output \"${FRAMEWORK}/${FRAMEWORK_NAME}\"\ncp -r \"${FRAMEWORK}\" \"$OUTPUT_DIR\"\n\n";
847
847
  };
848
848
  FAD3577022646BEF00419673 /* ShellScript */ = {
849
849
  isa = PBXShellScriptBuildPhase;