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,601 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ /**
4
+ * Welcome to Cocoa Lumberjack!
5
+ *
6
+ * The project page has a wealth of documentation if you have any questions.
7
+ * https://github.com/robbiehanson/CocoaLumberjack
8
+ *
9
+ * If you're new to the project you may wish to read the "Getting Started" wiki.
10
+ * https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted
11
+ *
12
+ * Otherwise, here is a quick refresher.
13
+ * There are three steps to using the macros:
14
+ *
15
+ * Step 1:
16
+ * Import the header in your implementation file:
17
+ *
18
+ * #import "DDLog.h"
19
+ *
20
+ * Step 2:
21
+ * Define your logging level in your implementation file:
22
+ *
23
+ * // Log levels: off, error, warn, info, verbose
24
+ * static const int ddLogLevel = LOG_LEVEL_VERBOSE;
25
+ *
26
+ * Step 3:
27
+ * Replace your NSLog statements with DDLog statements according to the severity of the message.
28
+ *
29
+ * NSLog(@"Fatal error, no dohickey found!"); -> DDLogError(@"Fatal error, no dohickey found!");
30
+ *
31
+ * DDLog works exactly the same as NSLog.
32
+ * This means you can pass it multiple variables just like NSLog.
33
+ **/
34
+
35
+
36
+ @class DDLogMessage;
37
+
38
+ @protocol DDLogger;
39
+ @protocol DDLogFormatter;
40
+
41
+ /**
42
+ * This is the single macro that all other macros below compile into.
43
+ * This big multiline macro makes all the other macros easier to read.
44
+ **/
45
+
46
+ #define LOG_MACRO(isAsynchronous, lvl, flg, ctx, atag, fnct, frmt, ...) \
47
+ [DDLog log:isAsynchronous \
48
+ level:lvl \
49
+ flag:flg \
50
+ context:ctx \
51
+ file:__FILE__ \
52
+ function:fnct \
53
+ line:__LINE__ \
54
+ tag:atag \
55
+ format:(frmt), ##__VA_ARGS__]
56
+
57
+ /**
58
+ * Define the Objective-C and C versions of the macro.
59
+ * These automatically inject the proper function name for either an objective-c method or c function.
60
+ *
61
+ * We also define shorthand versions for asynchronous and synchronous logging.
62
+ **/
63
+
64
+ #define LOG_OBJC_MACRO(async, lvl, flg, ctx, frmt, ...) \
65
+ LOG_MACRO(async, lvl, flg, ctx, nil, sel_getName(_cmd), frmt, ##__VA_ARGS__)
66
+
67
+ #define LOG_C_MACRO(async, lvl, flg, ctx, frmt, ...) \
68
+ LOG_MACRO(async, lvl, flg, ctx, nil, __FUNCTION__, frmt, ##__VA_ARGS__)
69
+
70
+ #define SYNC_LOG_OBJC_MACRO(lvl, flg, ctx, frmt, ...) \
71
+ LOG_OBJC_MACRO( NO, lvl, flg, ctx, frmt, ##__VA_ARGS__)
72
+
73
+ #define ASYNC_LOG_OBJC_MACRO(lvl, flg, ctx, frmt, ...) \
74
+ LOG_OBJC_MACRO(YES, lvl, flg, ctx, frmt, ##__VA_ARGS__)
75
+
76
+ #define SYNC_LOG_C_MACRO(lvl, flg, ctx, frmt, ...) \
77
+ LOG_C_MACRO( NO, lvl, flg, ctx, frmt, ##__VA_ARGS__)
78
+
79
+ #define ASYNC_LOG_C_MACRO(lvl, flg, ctx, frmt, ...) \
80
+ LOG_C_MACRO(YES, lvl, flg, ctx, frmt, ##__VA_ARGS__)
81
+
82
+ /**
83
+ * Define version of the macro that only execute if the logLevel is above the threshold.
84
+ * The compiled versions essentially look like this:
85
+ *
86
+ * if (logFlagForThisLogMsg & ddLogLevel) { execute log message }
87
+ *
88
+ * As shown further below, Lumberjack actually uses a bitmask as opposed to primitive log levels.
89
+ * This allows for a great amount of flexibility and some pretty advanced fine grained logging techniques.
90
+ *
91
+ * Note that when compiler optimizations are enabled (as they are for your release builds),
92
+ * the log messages above your logging threshold will automatically be compiled out.
93
+ *
94
+ * (If the compiler sees ddLogLevel declared as a constant, the compiler simply checks to see if the 'if' statement
95
+ * would execute, and if not it strips it from the binary.)
96
+ *
97
+ * We also define shorthand versions for asynchronous and synchronous logging.
98
+ **/
99
+
100
+ #define LOG_MAYBE(async, lvl, flg, ctx, fnct, frmt, ...) \
101
+ do { if(lvl & flg) LOG_MACRO(async, lvl, flg, ctx, nil, fnct, frmt, ##__VA_ARGS__); } while(0)
102
+
103
+ #define LOG_OBJC_MAYBE(async, lvl, flg, ctx, frmt, ...) \
104
+ LOG_MAYBE(async, lvl, flg, ctx, sel_getName(_cmd), frmt, ##__VA_ARGS__)
105
+
106
+ #define LOG_C_MAYBE(async, lvl, flg, ctx, frmt, ...) \
107
+ LOG_MAYBE(async, lvl, flg, ctx, __FUNCTION__, frmt, ##__VA_ARGS__)
108
+
109
+ #define SYNC_LOG_OBJC_MAYBE(lvl, flg, ctx, frmt, ...) \
110
+ LOG_OBJC_MAYBE( NO, lvl, flg, ctx, frmt, ##__VA_ARGS__)
111
+
112
+ #define ASYNC_LOG_OBJC_MAYBE(lvl, flg, ctx, frmt, ...) \
113
+ LOG_OBJC_MAYBE(YES, lvl, flg, ctx, frmt, ##__VA_ARGS__)
114
+
115
+ #define SYNC_LOG_C_MAYBE(lvl, flg, ctx, frmt, ...) \
116
+ LOG_C_MAYBE( NO, lvl, flg, ctx, frmt, ##__VA_ARGS__)
117
+
118
+ #define ASYNC_LOG_C_MAYBE(lvl, flg, ctx, frmt, ...) \
119
+ LOG_C_MAYBE(YES, lvl, flg, ctx, frmt, ##__VA_ARGS__)
120
+
121
+ /**
122
+ * Define versions of the macros that also accept tags.
123
+ *
124
+ * The DDLogMessage object includes a 'tag' ivar that may be used for a variety of purposes.
125
+ * It may be used to pass custom information to loggers or formatters.
126
+ * Or it may be used by 3rd party extensions to the framework.
127
+ *
128
+ * Thes macros just make it a little easier to extend logging functionality.
129
+ **/
130
+
131
+ #define LOG_OBJC_TAG_MACRO(async, lvl, flg, ctx, tag, frmt, ...) \
132
+ LOG_MACRO(async, lvl, flg, ctx, tag, sel_getName(_cmd), frmt, ##__VA_ARGS__)
133
+
134
+ #define LOG_C_TAG_MACRO(async, lvl, flg, ctx, tag, frmt, ...) \
135
+ LOG_MACRO(async, lvl, flg, ctx, tag, __FUNCTION__, frmt, ##__VA_ARGS__)
136
+
137
+ #define LOG_TAG_MAYBE(async, lvl, flg, ctx, tag, fnct, frmt, ...) \
138
+ do { if(lvl & flg) LOG_MACRO(async, lvl, flg, ctx, tag, fnct, frmt, ##__VA_ARGS__); } while(0)
139
+
140
+ #define LOG_OBJC_TAG_MAYBE(async, lvl, flg, ctx, tag, frmt, ...) \
141
+ LOG_TAG_MAYBE(async, lvl, flg, ctx, tag, sel_getName(_cmd), frmt, ##__VA_ARGS__)
142
+
143
+ #define LOG_C_TAG_MAYBE(async, lvl, flg, ctx, tag, frmt, ...) \
144
+ LOG_TAG_MAYBE(async, lvl, flg, ctx, tag, __FUNCTION__, frmt, ##__VA_ARGS__)
145
+
146
+ /**
147
+ * Define the standard options.
148
+ *
149
+ * We default to only 4 levels because it makes it easier for beginners
150
+ * to make the transition to a logging framework.
151
+ *
152
+ * More advanced users may choose to completely customize the levels (and level names) to suite their needs.
153
+ * For more information on this see the "Custom Log Levels" page:
154
+ * https://github.com/robbiehanson/CocoaLumberjack/wiki/CustomLogLevels
155
+ *
156
+ * Advanced users may also notice that we're using a bitmask.
157
+ * This is to allow for custom fine grained logging:
158
+ * https://github.com/robbiehanson/CocoaLumberjack/wiki/FineGrainedLogging
159
+ *
160
+ * -- Flags --
161
+ *
162
+ * Typically you will use the LOG_LEVELS (see below), but the flags may be used directly in certain situations.
163
+ * For example, say you have a lot of warning log messages, and you wanted to disable them.
164
+ * However, you still needed to see your error and info log messages.
165
+ * You could accomplish that with the following:
166
+ *
167
+ * static const int ddLogLevel = LOG_FLAG_ERROR | LOG_FLAG_INFO;
168
+ *
169
+ * Flags may also be consulted when writing custom log formatters,
170
+ * as the DDLogMessage class captures the individual flag that caused the log message to fire.
171
+ *
172
+ * -- Levels --
173
+ *
174
+ * Log levels are simply the proper bitmask of the flags.
175
+ *
176
+ * -- Booleans --
177
+ *
178
+ * The booleans may be used when your logging code involves more than one line.
179
+ * For example:
180
+ *
181
+ * if (LOG_VERBOSE) {
182
+ * for (id sprocket in sprockets)
183
+ * DDLogVerbose(@"sprocket: %@", [sprocket description])
184
+ * }
185
+ *
186
+ * -- Async --
187
+ *
188
+ * Defines the default asynchronous options.
189
+ * The default philosophy for asynchronous logging is very simple:
190
+ *
191
+ * Log messages with errors should be executed synchronously.
192
+ * After all, an error just occurred. The application could be unstable.
193
+ *
194
+ * All other log messages, such as debug output, are executed asynchronously.
195
+ * After all, if it wasn't an error, then it was just informational output,
196
+ * or something the application was easily able to recover from.
197
+ *
198
+ * -- Changes --
199
+ *
200
+ * You are strongly discouraged from modifying this file.
201
+ * If you do, you make it more difficult on yourself to merge future bug fixes and improvements from the project.
202
+ * Instead, create your own MyLogging.h or ApplicationNameLogging.h or CompanyLogging.h
203
+ *
204
+ * For an example of customizing your logging experience, see the "Custom Log Levels" page:
205
+ * https://github.com/robbiehanson/CocoaLumberjack/wiki/CustomLogLevels
206
+ **/
207
+
208
+ #define LOG_FLAG_ERROR (1 << 0) // 0...0001
209
+ #define LOG_FLAG_WARN (1 << 1) // 0...0010
210
+ #define LOG_FLAG_INFO (1 << 2) // 0...0100
211
+ #define LOG_FLAG_VERBOSE (1 << 3) // 0...1000
212
+
213
+ #define LOG_LEVEL_OFF 0
214
+ #define LOG_LEVEL_ERROR (LOG_FLAG_ERROR) // 0...0001
215
+ #define LOG_LEVEL_WARN (LOG_FLAG_ERROR | LOG_FLAG_WARN) // 0...0011
216
+ #define LOG_LEVEL_INFO (LOG_FLAG_ERROR | LOG_FLAG_WARN | LOG_FLAG_INFO) // 0...0111
217
+ #define LOG_LEVEL_VERBOSE (LOG_FLAG_ERROR | LOG_FLAG_WARN | LOG_FLAG_INFO | LOG_FLAG_VERBOSE) // 0...1111
218
+
219
+ #define LOG_ERROR (ddLogLevel & LOG_FLAG_ERROR)
220
+ #define LOG_WARN (ddLogLevel & LOG_FLAG_WARN)
221
+ #define LOG_INFO (ddLogLevel & LOG_FLAG_INFO)
222
+ #define LOG_VERBOSE (ddLogLevel & LOG_FLAG_VERBOSE)
223
+
224
+ #define LOG_ASYNC_ENABLED YES
225
+
226
+ #define LOG_ASYNC_ERROR ( NO && LOG_ASYNC_ENABLED)
227
+ #define LOG_ASYNC_WARN (YES && LOG_ASYNC_ENABLED)
228
+ #define LOG_ASYNC_INFO (YES && LOG_ASYNC_ENABLED)
229
+ #define LOG_ASYNC_VERBOSE (YES && LOG_ASYNC_ENABLED)
230
+
231
+ #define DDLogError(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_ERROR, ddLogLevel, LOG_FLAG_ERROR, 0, frmt, ##__VA_ARGS__)
232
+ #define DDLogWarn(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_WARN, ddLogLevel, LOG_FLAG_WARN, 0, frmt, ##__VA_ARGS__)
233
+ #define DDLogInfo(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_INFO, ddLogLevel, LOG_FLAG_INFO, 0, frmt, ##__VA_ARGS__)
234
+ #define DDLogVerbose(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_VERBOSE, ddLogLevel, LOG_FLAG_VERBOSE, 0, frmt, ##__VA_ARGS__)
235
+
236
+ #define DDLogCError(frmt, ...) LOG_C_MAYBE(LOG_ASYNC_ERROR, ddLogLevel, LOG_FLAG_ERROR, 0, frmt, ##__VA_ARGS__)
237
+ #define DDLogCWarn(frmt, ...) LOG_C_MAYBE(LOG_ASYNC_WARN, ddLogLevel, LOG_FLAG_WARN, 0, frmt, ##__VA_ARGS__)
238
+ #define DDLogCInfo(frmt, ...) LOG_C_MAYBE(LOG_ASYNC_INFO, ddLogLevel, LOG_FLAG_INFO, 0, frmt, ##__VA_ARGS__)
239
+ #define DDLogCVerbose(frmt, ...) LOG_C_MAYBE(LOG_ASYNC_VERBOSE, ddLogLevel, LOG_FLAG_VERBOSE, 0, frmt, ##__VA_ARGS__)
240
+
241
+ /**
242
+ * The THIS_FILE macro gives you an NSString of the file name.
243
+ * For simplicity and clarity, the file name does not include the full path or file extension.
244
+ *
245
+ * For example: DDLogWarn(@"%@: Unable to find thingy", THIS_FILE) -> @"MyViewController: Unable to find thingy"
246
+ **/
247
+
248
+ NSString *DDExtractFileNameWithoutExtension(const char *filePath, BOOL copy);
249
+
250
+ #define THIS_FILE (DDExtractFileNameWithoutExtension(__FILE__, NO))
251
+
252
+ /**
253
+ * The THIS_METHOD macro gives you the name of the current objective-c method.
254
+ *
255
+ * For example: DDLogWarn(@"%@ - Requires non-nil strings", THIS_METHOD) -> @"setMake:model: requires non-nil strings"
256
+ *
257
+ * Note: This does NOT work in straight C functions (non objective-c).
258
+ * Instead you should use the predefined __FUNCTION__ macro.
259
+ **/
260
+
261
+ #define THIS_METHOD NSStringFromSelector(_cmd)
262
+
263
+
264
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
265
+ #pragma mark -
266
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
267
+
268
+ @interface DDLog : NSObject
269
+
270
+ /**
271
+ * Provides access to the underlying logging queue.
272
+ * This may be helpful to Logger classes for things like thread synchronization.
273
+ **/
274
+
275
+ + (dispatch_queue_t)loggingQueue;
276
+
277
+ /**
278
+ * Logging Primitive.
279
+ *
280
+ * This method is used by the macros above.
281
+ * It is suggested you stick with the macros as they're easier to use.
282
+ **/
283
+
284
+ + (void)log:(BOOL)synchronous
285
+ level:(int)level
286
+ flag:(int)flag
287
+ context:(int)context
288
+ file:(const char *)file
289
+ function:(const char *)function
290
+ line:(int)line
291
+ tag:(id)tag
292
+ format:(NSString *)format, ... __attribute__ ((format (__NSString__, 9, 10)));
293
+
294
+ /**
295
+ * Logging Primitive.
296
+ *
297
+ * This method can be used if you have a prepared va_list.
298
+ **/
299
+
300
+ + (void)log:(BOOL)asynchronous
301
+ level:(int)level
302
+ flag:(int)flag
303
+ context:(int)context
304
+ file:(const char *)file
305
+ function:(const char *)function
306
+ line:(int)line
307
+ tag:(id)tag
308
+ format:(NSString *)format
309
+ args:(va_list)argList;
310
+
311
+
312
+ /**
313
+ * Since logging can be asynchronous, there may be times when you want to flush the logs.
314
+ * The framework invokes this automatically when the application quits.
315
+ **/
316
+
317
+ + (void)flushLog;
318
+
319
+ /**
320
+ * Loggers
321
+ *
322
+ * If you want your log statements to go somewhere,
323
+ * you should create and add a logger.
324
+ **/
325
+
326
+ + (void)addLogger:(id <DDLogger>)logger;
327
+ + (void)removeLogger:(id <DDLogger>)logger;
328
+
329
+ + (void)removeAllLoggers;
330
+
331
+ /**
332
+ * Registered Dynamic Logging
333
+ *
334
+ * These methods allow you to obtain a list of classes that are using registered dynamic logging,
335
+ * and also provides methods to get and set their log level during run time.
336
+ **/
337
+
338
+ + (NSArray *)registeredClasses;
339
+ + (NSArray *)registeredClassNames;
340
+
341
+ + (int)logLevelForClass:(Class)aClass;
342
+ + (int)logLevelForClassWithName:(NSString *)aClassName;
343
+
344
+ + (void)setLogLevel:(int)logLevel forClass:(Class)aClass;
345
+ + (void)setLogLevel:(int)logLevel forClassWithName:(NSString *)aClassName;
346
+
347
+ @end
348
+
349
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
350
+ #pragma mark -
351
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
352
+
353
+ @protocol DDLogger <NSObject>
354
+ @required
355
+
356
+ - (void)logMessage:(DDLogMessage *)logMessage;
357
+
358
+ /**
359
+ * Formatters may optionally be added to any logger.
360
+ *
361
+ * If no formatter is set, the logger simply logs the message as it is given in logMessage,
362
+ * or it may use its own built in formatting style.
363
+ **/
364
+ - (id <DDLogFormatter>)logFormatter;
365
+ - (void)setLogFormatter:(id <DDLogFormatter>)formatter;
366
+
367
+ @optional
368
+
369
+ /**
370
+ * Since logging is asynchronous, adding and removing loggers is also asynchronous.
371
+ * In other words, the loggers are added and removed at appropriate times with regards to log messages.
372
+ *
373
+ * - Loggers will not receive log messages that were executed prior to when they were added.
374
+ * - Loggers will not receive log messages that were executed after they were removed.
375
+ *
376
+ * These methods are executed in the logging thread/queue.
377
+ * This is the same thread/queue that will execute every logMessage: invocation.
378
+ * Loggers may use these methods for thread synchronization or other setup/teardown tasks.
379
+ **/
380
+ - (void)didAddLogger;
381
+ - (void)willRemoveLogger;
382
+
383
+ /**
384
+ * Some loggers may buffer IO for optimization purposes.
385
+ * For example, a database logger may only save occasionaly as the disk IO is slow.
386
+ * In such loggers, this method should be implemented to flush any pending IO.
387
+ *
388
+ * This allows invocations of DDLog's flushLog method to be propogated to loggers that need it.
389
+ *
390
+ * Note that DDLog's flushLog method is invoked automatically when the application quits,
391
+ * and it may be also invoked manually by the developer prior to application crashes, or other such reasons.
392
+ **/
393
+ - (void)flush;
394
+
395
+ /**
396
+ * Each logger is executed concurrently with respect to the other loggers.
397
+ * Thus, a dedicated dispatch queue is used for each logger.
398
+ * Logger implementations may optionally choose to provide their own dispatch queue.
399
+ **/
400
+ - (dispatch_queue_t)loggerQueue;
401
+
402
+ /**
403
+ * If the logger implementation does not choose to provide its own queue,
404
+ * one will automatically be created for it.
405
+ * The created queue will receive its name from this method.
406
+ * This may be helpful for debugging or profiling reasons.
407
+ **/
408
+ - (NSString *)loggerName;
409
+
410
+ @end
411
+
412
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
413
+ #pragma mark -
414
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
415
+
416
+ @protocol DDLogFormatter <NSObject>
417
+ @required
418
+
419
+ /**
420
+ * Formatters may optionally be added to any logger.
421
+ * This allows for increased flexibility in the logging environment.
422
+ * For example, log messages for log files may be formatted differently than log messages for the console.
423
+ *
424
+ * For more information about formatters, see the "Custom Formatters" page:
425
+ * https://github.com/robbiehanson/CocoaLumberjack/wiki/CustomFormatters
426
+ *
427
+ * The formatter may also optionally filter the log message by returning nil,
428
+ * in which case the logger will not log the message.
429
+ **/
430
+ - (NSString *)formatLogMessage:(DDLogMessage *)logMessage;
431
+
432
+ @optional
433
+
434
+ /**
435
+ * A single formatter instance can be added to multiple loggers.
436
+ * These methods provides hooks to notify the formatter of when it's added/removed.
437
+ *
438
+ * This is primarily for thread-safety.
439
+ * If a formatter is explicitly not thread-safe, it may wish to throw an exception if added to multiple loggers.
440
+ * Or if a formatter has potentially thread-unsafe code (e.g. NSDateFormatter),
441
+ * it could possibly use these hooks to switch to thread-safe versions of the code.
442
+ **/
443
+ - (void)didAddToLogger:(id <DDLogger>)logger;
444
+ - (void)willRemoveFromLogger:(id <DDLogger>)logger;
445
+
446
+ @end
447
+
448
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
449
+ #pragma mark -
450
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
451
+
452
+ @protocol DDRegisteredDynamicLogging
453
+
454
+ /**
455
+ * Implement these methods to allow a file's log level to be managed from a central location.
456
+ *
457
+ * This is useful if you'd like to be able to change log levels for various parts
458
+ * of your code from within the running application.
459
+ *
460
+ * Imagine pulling up the settings for your application,
461
+ * and being able to configure the logging level on a per file basis.
462
+ *
463
+ * The implementation can be very straight-forward:
464
+ *
465
+ * + (int)ddLogLevel
466
+ * {
467
+ * return ddLogLevel;
468
+ * }
469
+ *
470
+ * + (void)ddSetLogLevel:(int)logLevel
471
+ * {
472
+ * ddLogLevel = logLevel;
473
+ * }
474
+ **/
475
+
476
+ + (int)ddLogLevel;
477
+ + (void)ddSetLogLevel:(int)logLevel;
478
+
479
+ @end
480
+
481
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
482
+ #pragma mark -
483
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
484
+
485
+ /**
486
+ * The DDLogMessage class encapsulates information about the log message.
487
+ * If you write custom loggers or formatters, you will be dealing with objects of this class.
488
+ **/
489
+
490
+ enum {
491
+ DDLogMessageCopyFile = 1 << 0,
492
+ DDLogMessageCopyFunction = 1 << 1
493
+ };
494
+ typedef int DDLogMessageOptions;
495
+
496
+ @interface DDLogMessage : NSObject
497
+ {
498
+
499
+ // The public variables below can be accessed directly (for speed).
500
+ // For example: logMessage->logLevel
501
+
502
+ @public
503
+ int logLevel;
504
+ int logFlag;
505
+ int logContext;
506
+ NSString *logMsg;
507
+ NSDate *timestamp;
508
+ char *file;
509
+ char *function;
510
+ int lineNumber;
511
+ mach_port_t machThreadID;
512
+ char *queueLabel;
513
+ NSString *threadName;
514
+
515
+ // For 3rd party extensions to the framework, where flags and contexts aren't enough.
516
+ id tag;
517
+
518
+ // For 3rd party extensions that manually create DDLogMessage instances.
519
+ DDLogMessageOptions options;
520
+ }
521
+
522
+ /**
523
+ * Standard init method for a log message object.
524
+ * Used by the logging primitives. (And the macros use the logging primitives.)
525
+ *
526
+ * If you find need to manually create logMessage objects, there is one thing you should be aware of:
527
+ *
528
+ * If no flags are passed, the method expects the file and function parameters to be string literals.
529
+ * That is, it expects the given strings to exist for the duration of the object's lifetime,
530
+ * and it expects the given strings to be immutable.
531
+ * In other words, it does not copy these strings, it simply points to them.
532
+ * This is due to the fact that __FILE__ and __FUNCTION__ are usually used to specify these parameters,
533
+ * so it makes sense to optimize and skip the unnecessary allocations.
534
+ * However, if you need them to be copied you may use the options parameter to specify this.
535
+ * Options is a bitmask which supports DDLogMessageCopyFile and DDLogMessageCopyFunction.
536
+ **/
537
+ - (id)initWithLogMsg:(NSString *)logMsg
538
+ level:(int)logLevel
539
+ flag:(int)logFlag
540
+ context:(int)logContext
541
+ file:(const char *)file
542
+ function:(const char *)function
543
+ line:(int)line
544
+ tag:(id)tag
545
+ options:(DDLogMessageOptions)optionsMask;
546
+
547
+ /**
548
+ * Returns the threadID as it appears in NSLog.
549
+ * That is, it is a hexadecimal value which is calculated from the machThreadID.
550
+ **/
551
+ - (NSString *)threadID;
552
+
553
+ /**
554
+ * Convenience property to get just the file name, as the file variable is generally the full file path.
555
+ * This method does not include the file extension, which is generally unwanted for logging purposes.
556
+ **/
557
+ - (NSString *)fileName;
558
+
559
+ /**
560
+ * Returns the function variable in NSString form.
561
+ **/
562
+ - (NSString *)methodName;
563
+
564
+ @end
565
+
566
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
567
+ #pragma mark -
568
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
569
+
570
+ /**
571
+ * The DDLogger protocol specifies that an optional formatter can be added to a logger.
572
+ * Most (but not all) loggers will want to support formatters.
573
+ *
574
+ * However, writting getters and setters in a thread safe manner,
575
+ * while still maintaining maximum speed for the logging process, is a difficult task.
576
+ *
577
+ * To do it right, the implementation of the getter/setter has strict requiremenets:
578
+ * - Must NOT require the logMessage method to acquire a lock.
579
+ * - Must NOT require the logMessage method to access an atomic property (also a lock of sorts).
580
+ *
581
+ * To simplify things, an abstract logger is provided that implements the getter and setter.
582
+ *
583
+ * Logger implementations may simply extend this class,
584
+ * and they can ACCESS THE FORMATTER VARIABLE DIRECTLY from within their logMessage method!
585
+ **/
586
+
587
+ @interface DDAbstractLogger : NSObject <DDLogger>
588
+ {
589
+ id <DDLogFormatter> formatter;
590
+
591
+ dispatch_queue_t loggerQueue;
592
+ }
593
+
594
+ - (id <DDLogFormatter>)logFormatter;
595
+ - (void)setLogFormatter:(id <DDLogFormatter>)formatter;
596
+
597
+ // For thread-safety assertions
598
+ - (BOOL)isOnGlobalLoggingQueue;
599
+ - (BOOL)isOnInternalLoggerQueue;
600
+
601
+ @end