motion-yapper 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (294) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +3 -1
  4. data/lib/yapper.rb +3 -3
  5. data/lib/yapper/db.rb +61 -4
  6. data/lib/yapper/document/persistence.rb +4 -0
  7. data/lib/yapper/document/selection.rb +13 -0
  8. data/lib/yapper/version.rb +1 -1
  9. data/motion-yapper.gemspec +1 -1
  10. data/spec/integration/search_spec.rb +111 -0
  11. data/vendor/Podfile.lock +11 -7
  12. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.bridgesupport +16 -2
  13. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.h +10 -7
  14. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.m +20 -2
  15. metadata +19 -297
  16. data/vendor/Pods/.build/libPods-CocoaLumberjack.a +0 -0
  17. data/vendor/Pods/.build/libPods-NSData+MD5Digest.a +0 -0
  18. data/vendor/Pods/.build/libPods-YapDatabase.a +0 -0
  19. data/vendor/Pods/.build/libPods.a +0 -0
  20. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDASLLogger.h +0 -41
  21. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDAbstractDatabaseLogger.h +0 -102
  22. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDContextFilterLogFormatter.h +0 -63
  23. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDDispatchQueueLogFormatter.h +0 -128
  24. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDFileLogger.h +0 -369
  25. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog+LOGV.h +0 -99
  26. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog.h +0 -634
  27. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDMultiFormatter.h +0 -30
  28. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDTTYLogger.h +0 -181
  29. data/vendor/Pods/BuildHeaders/NSData+MD5Digest/NSData+MD5Digest.h +0 -18
  30. data/vendor/Pods/BuildHeaders/YapDatabase/NSDictionary+YapDatabase.h +0 -8
  31. data/vendor/Pods/BuildHeaders/YapDatabase/YapCache.h +0 -91
  32. data/vendor/Pods/BuildHeaders/YapDatabase/YapCollectionKey.h +0 -23
  33. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabase.h +0 -547
  34. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnection.h +0 -449
  35. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnectionState.h +0 -29
  36. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseDefaults.h +0 -37
  37. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtension.h +0 -15
  38. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionConnection.h +0 -11
  39. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionPrivate.h +0 -444
  40. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionTransaction.h +0 -11
  41. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredView.h +0 -81
  42. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewConnection.h +0 -12
  43. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewPrivate.h +0 -17
  44. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTransaction.h +0 -39
  45. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTypes.h +0 -32
  46. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearch.h +0 -89
  47. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchConnection.h +0 -32
  48. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchPrivate.h +0 -77
  49. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +0 -79
  50. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchTransaction.h +0 -68
  51. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseLogging.h +0 -158
  52. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseManager.h +0 -17
  53. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabasePrivate.h +0 -446
  54. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseQuery.h +0 -42
  55. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationship.h +0 -35
  56. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipConnection.h +0 -29
  57. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdge.h +0 -163
  58. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdgePrivate.h +0 -79
  59. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipNode.h +0 -99
  60. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipOptions.h +0 -59
  61. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipPrivate.h +0 -125
  62. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipTransaction.h +0 -384
  63. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndex.h +0 -149
  64. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexConnection.h +0 -33
  65. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +0 -83
  66. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetup.h +0 -33
  67. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetupPrivate.h +0 -18
  68. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +0 -58
  69. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseStatement.h +0 -13
  70. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseString.h +0 -121
  71. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseTransaction.h +0 -651
  72. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseView.h +0 -127
  73. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChange.h +0 -272
  74. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChangePrivate.h +0 -94
  75. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewConnection.h +0 -116
  76. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappings.h +0 -842
  77. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappingsPrivate.h +0 -72
  78. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewOptions.h +0 -63
  79. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPage.h +0 -36
  80. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPageMetadata.h +0 -27
  81. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPrivate.h +0 -170
  82. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptions.h +0 -330
  83. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +0 -17
  84. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTransaction.h +0 -498
  85. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTypes.h +0 -99
  86. data/vendor/Pods/BuildHeaders/YapDatabase/YapMemoryTable.h +0 -74
  87. data/vendor/Pods/BuildHeaders/YapDatabase/YapNull.h +0 -17
  88. data/vendor/Pods/BuildHeaders/YapDatabase/YapSet.h +0 -41
  89. data/vendor/Pods/BuildHeaders/YapDatabase/YapTouch.h +0 -15
  90. data/vendor/Pods/CocoaLumberjack/LICENSE.txt +0 -18
  91. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h +0 -41
  92. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m +0 -100
  93. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h +0 -102
  94. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m +0 -727
  95. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h +0 -369
  96. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m +0 -1539
  97. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog+LOGV.h +0 -99
  98. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.h +0 -634
  99. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.m +0 -1208
  100. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h +0 -181
  101. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m +0 -1520
  102. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDContextFilterLogFormatter.h +0 -63
  103. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDContextFilterLogFormatter.m +0 -191
  104. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDDispatchQueueLogFormatter.h +0 -128
  105. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDDispatchQueueLogFormatter.m +0 -253
  106. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.h +0 -30
  107. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.m +0 -127
  108. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt +0 -7
  109. data/vendor/Pods/CocoaLumberjack/README.markdown +0 -74
  110. data/vendor/Pods/Headers/CocoaLumberjack/DDASLLogger.h +0 -41
  111. data/vendor/Pods/Headers/CocoaLumberjack/DDAbstractDatabaseLogger.h +0 -102
  112. data/vendor/Pods/Headers/CocoaLumberjack/DDContextFilterLogFormatter.h +0 -63
  113. data/vendor/Pods/Headers/CocoaLumberjack/DDDispatchQueueLogFormatter.h +0 -128
  114. data/vendor/Pods/Headers/CocoaLumberjack/DDFileLogger.h +0 -369
  115. data/vendor/Pods/Headers/CocoaLumberjack/DDLog+LOGV.h +0 -99
  116. data/vendor/Pods/Headers/CocoaLumberjack/DDLog.h +0 -634
  117. data/vendor/Pods/Headers/CocoaLumberjack/DDMultiFormatter.h +0 -30
  118. data/vendor/Pods/Headers/CocoaLumberjack/DDTTYLogger.h +0 -181
  119. data/vendor/Pods/Headers/NSData+MD5Digest/NSData+MD5Digest.h +0 -18
  120. data/vendor/Pods/Headers/YapDatabase/YapCollectionKey.h +0 -23
  121. data/vendor/Pods/Headers/YapDatabase/YapDatabase.h +0 -547
  122. data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnection.h +0 -449
  123. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtension.h +0 -15
  124. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionConnection.h +0 -11
  125. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionTransaction.h +0 -11
  126. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredView.h +0 -81
  127. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewConnection.h +0 -12
  128. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTransaction.h +0 -39
  129. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTypes.h +0 -32
  130. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearch.h +0 -89
  131. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchConnection.h +0 -32
  132. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +0 -79
  133. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchTransaction.h +0 -68
  134. data/vendor/Pods/Headers/YapDatabase/YapDatabaseQuery.h +0 -42
  135. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationship.h +0 -35
  136. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipConnection.h +0 -29
  137. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipEdge.h +0 -163
  138. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipNode.h +0 -99
  139. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipOptions.h +0 -59
  140. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipTransaction.h +0 -384
  141. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndex.h +0 -149
  142. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexConnection.h +0 -33
  143. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexSetup.h +0 -33
  144. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +0 -58
  145. data/vendor/Pods/Headers/YapDatabase/YapDatabaseTransaction.h +0 -651
  146. data/vendor/Pods/Headers/YapDatabase/YapDatabaseView.h +0 -127
  147. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChange.h +0 -272
  148. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewConnection.h +0 -116
  149. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappings.h +0 -842
  150. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewOptions.h +0 -63
  151. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptions.h +0 -330
  152. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTransaction.h +0 -498
  153. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTypes.h +0 -99
  154. data/vendor/Pods/Headers/YapDatabase/YapSet.h +0 -41
  155. data/vendor/Pods/Headers/____Pods-CocoaLumberjack-prefix.h +0 -7
  156. data/vendor/Pods/Headers/____Pods-NSData+MD5Digest-prefix.h +0 -5
  157. data/vendor/Pods/Headers/____Pods-YapDatabase-prefix.h +0 -5
  158. data/vendor/Pods/Headers/____Pods-environment.h +0 -38
  159. data/vendor/Pods/Manifest.lock +0 -22
  160. data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.h +0 -18
  161. data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.m +0 -39
  162. data/vendor/Pods/NSData+MD5Digest/README.md +0 -11
  163. data/vendor/Pods/Pods-CocoaLumberjack-Private.xcconfig +0 -5
  164. data/vendor/Pods/Pods-CocoaLumberjack-dummy.m +0 -5
  165. data/vendor/Pods/Pods-CocoaLumberjack-prefix.pch +0 -7
  166. data/vendor/Pods/Pods-CocoaLumberjack.xcconfig +0 -0
  167. data/vendor/Pods/Pods-NSData+MD5Digest-Private.xcconfig +0 -5
  168. data/vendor/Pods/Pods-NSData+MD5Digest-dummy.m +0 -5
  169. data/vendor/Pods/Pods-NSData+MD5Digest-prefix.pch +0 -5
  170. data/vendor/Pods/Pods-NSData+MD5Digest.xcconfig +0 -0
  171. data/vendor/Pods/Pods-YapDatabase-Private.xcconfig +0 -5
  172. data/vendor/Pods/Pods-YapDatabase-dummy.m +0 -5
  173. data/vendor/Pods/Pods-YapDatabase-prefix.pch +0 -5
  174. data/vendor/Pods/Pods-YapDatabase.xcconfig +0 -1
  175. data/vendor/Pods/Pods-acknowledgements.markdown +0 -59
  176. data/vendor/Pods/Pods-acknowledgements.plist +0 -97
  177. data/vendor/Pods/Pods-dummy.m +0 -5
  178. data/vendor/Pods/Pods-environment.h +0 -38
  179. data/vendor/Pods/Pods-resources.sh +0 -68
  180. data/vendor/Pods/Pods.xcconfig +0 -5
  181. data/vendor/Pods/Pods.xcodeproj/project.pbxproj +0 -4807
  182. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-CocoaLumberjack.xcscheme +0 -59
  183. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-NSData+MD5Digest.xcscheme +0 -59
  184. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-YapDatabase.xcscheme +0 -59
  185. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods.xcscheme +0 -59
  186. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/xcschememanagement.plist +0 -31
  187. data/vendor/Pods/YapDatabase/LICENSE.txt +0 -18
  188. data/vendor/Pods/YapDatabase/README.md +0 -32
  189. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/Internal/YapDatabaseFilteredViewPrivate.h +0 -17
  190. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.h +0 -81
  191. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.m +0 -159
  192. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.h +0 -12
  193. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.m +0 -41
  194. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.h +0 -39
  195. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.m +0 -1235
  196. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTypes.h +0 -32
  197. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/Internal/YapDatabaseFullTextSearchPrivate.h +0 -77
  198. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.h +0 -89
  199. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.m +0 -146
  200. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.h +0 -32
  201. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.m +0 -298
  202. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.h +0 -79
  203. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.m +0 -95
  204. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.h +0 -68
  205. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.m +0 -1403
  206. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/Internal/YapDatabaseExtensionPrivate.h +0 -444
  207. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.h +0 -15
  208. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.m +0 -83
  209. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.h +0 -11
  210. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.m +0 -46
  211. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.h +0 -11
  212. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.m +0 -204
  213. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipEdgePrivate.h +0 -79
  214. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipPrivate.h +0 -125
  215. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.h +0 -35
  216. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.m +0 -129
  217. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.h +0 -29
  218. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.m +0 -802
  219. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.h +0 -163
  220. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.m +0 -408
  221. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipNode.h +0 -99
  222. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.h +0 -59
  223. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.m +0 -29
  224. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.h +0 -384
  225. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.m +0 -5254
  226. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexPrivate.h +0 -83
  227. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexSetupPrivate.h +0 -18
  228. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.h +0 -149
  229. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.m +0 -161
  230. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.h +0 -33
  231. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.m +0 -331
  232. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.h +0 -33
  233. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.m +0 -245
  234. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.h +0 -58
  235. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +0 -1269
  236. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewChangePrivate.h +0 -94
  237. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewMappingsPrivate.h +0 -72
  238. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.h +0 -36
  239. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.mm +0 -296
  240. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.h +0 -27
  241. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.m +0 -28
  242. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPrivate.h +0 -170
  243. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewRangeOptionsPrivate.h +0 -17
  244. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.h +0 -272
  245. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m +0 -2500
  246. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.h +0 -842
  247. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.m +0 -1714
  248. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.h +0 -330
  249. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.m +0 -141
  250. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.h +0 -127
  251. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.m +0 -194
  252. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.h +0 -116
  253. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.m +0 -888
  254. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.h +0 -63
  255. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.m +0 -27
  256. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.h +0 -498
  257. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.m +0 -4986
  258. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTypes.h +0 -99
  259. data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.h +0 -8
  260. data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.m +0 -19
  261. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.h +0 -91
  262. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.m +0 -465
  263. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.h +0 -29
  264. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.m +0 -48
  265. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.h +0 -37
  266. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.m +0 -83
  267. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.h +0 -158
  268. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.m +0 -73
  269. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.h +0 -17
  270. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.m +0 -56
  271. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabasePrivate.h +0 -446
  272. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.h +0 -13
  273. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.m +0 -26
  274. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseString.h +0 -121
  275. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.h +0 -74
  276. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.m +0 -603
  277. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.h +0 -17
  278. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.m +0 -35
  279. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.h +0 -15
  280. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.m +0 -31
  281. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.h +0 -23
  282. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.m +0 -199
  283. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.h +0 -42
  284. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.m +0 -96
  285. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.h +0 -41
  286. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.m +0 -82
  287. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.h +0 -547
  288. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.m +0 -2013
  289. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.h +0 -449
  290. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.m +0 -4046
  291. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.h +0 -651
  292. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.m +0 -5602
  293. data/vendor/Pods/build-iPhoneSimulator/Pods.bridgesupport +0 -3172
  294. data/vendor/Pods/build-iPhoneSimulator/libPods.a +0 -0
@@ -1,181 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
- #if TARGET_OS_IPHONE
3
- #import <UIKit/UIColor.h> // iOS
4
- #elif !defined (COCOAPODS_POD_AVAILABLE_CocoaLumberjack_CLI)
5
- #import <AppKit/NSColor.h> // OS X with AppKit
6
- #else
7
- #import "CLIColor.h" // OS X without AppKit
8
- #endif
9
-
10
- #import "DDLog.h"
11
-
12
- #define LOG_CONTEXT_ALL INT_MAX
13
-
14
- /**
15
- * Welcome to Cocoa Lumberjack!
16
- *
17
- * The project page has a wealth of documentation if you have any questions.
18
- * https://github.com/CocoaLumberjack/CocoaLumberjack
19
- *
20
- * If you're new to the project you may wish to read the "Getting Started" wiki.
21
- * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
22
- *
23
- *
24
- * This class provides a logger for Terminal output or Xcode console output,
25
- * depending on where you are running your code.
26
- *
27
- * As described in the "Getting Started" page,
28
- * the traditional NSLog() function directs it's output to two places:
29
- *
30
- * - Apple System Log (so it shows up in Console.app)
31
- * - StdErr (if stderr is a TTY, so log statements show up in Xcode console)
32
- *
33
- * To duplicate NSLog() functionality you can simply add this logger and an asl logger.
34
- * However, if you instead choose to use file logging (for faster performance),
35
- * you may choose to use only a file logger and a tty logger.
36
- **/
37
-
38
- @interface DDTTYLogger : DDAbstractLogger <DDLogger>
39
- {
40
- NSCalendar *calendar;
41
- NSUInteger calendarUnitFlags;
42
-
43
- NSString *appName;
44
- char *app;
45
- size_t appLen;
46
-
47
- NSString *processID;
48
- char *pid;
49
- size_t pidLen;
50
-
51
- BOOL colorsEnabled;
52
- NSMutableArray *colorProfilesArray;
53
- NSMutableDictionary *colorProfilesDict;
54
- }
55
-
56
- + (instancetype)sharedInstance;
57
-
58
- /* Inherited from the DDLogger protocol:
59
- *
60
- * Formatters may optionally be added to any logger.
61
- *
62
- * If no formatter is set, the logger simply logs the message as it is given in logMessage,
63
- * or it may use its own built in formatting style.
64
- *
65
- * More information about formatters can be found here:
66
- * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/CustomFormatters
67
- *
68
- * The actual implementation of these methods is inherited from DDAbstractLogger.
69
-
70
- - (id <DDLogFormatter>)logFormatter;
71
- - (void)setLogFormatter:(id <DDLogFormatter>)formatter;
72
-
73
- */
74
-
75
- /**
76
- * Want to use different colors for different log levels?
77
- * Enable this property.
78
- *
79
- * If you run the application via the Terminal (not Xcode),
80
- * the logger will map colors to xterm-256color or xterm-color (if available).
81
- *
82
- * Xcode does NOT natively support colors in the Xcode debugging console.
83
- * You'll need to install the XcodeColors plugin to see colors in the Xcode console.
84
- * https://github.com/robbiehanson/XcodeColors
85
- *
86
- * The default value if NO.
87
- **/
88
- @property (readwrite, assign) BOOL colorsEnabled;
89
-
90
- /**
91
- * The default color set (foregroundColor, backgroundColor) is:
92
- *
93
- * - LOG_FLAG_ERROR = (red, nil)
94
- * - LOG_FLAG_WARN = (orange, nil)
95
- *
96
- * You can customize the colors however you see fit.
97
- * Please note that you are passing a flag, NOT a level.
98
- *
99
- * GOOD : [ttyLogger setForegroundColor:pink backgroundColor:nil forFlag:LOG_FLAG_INFO]; // <- Good :)
100
- * BAD : [ttyLogger setForegroundColor:pink backgroundColor:nil forFlag:LOG_LEVEL_INFO]; // <- BAD! :(
101
- *
102
- * LOG_FLAG_INFO = 0...00100
103
- * LOG_LEVEL_INFO = 0...00111 <- Would match LOG_FLAG_INFO and LOG_FLAG_WARN and LOG_FLAG_ERROR
104
- *
105
- * If you run the application within Xcode, then the XcodeColors plugin is required.
106
- *
107
- * If you run the application from a shell, then DDTTYLogger will automatically map the given color to
108
- * the closest available color. (xterm-256color or xterm-color which have 256 and 16 supported colors respectively.)
109
- *
110
- * This method invokes setForegroundColor:backgroundColor:forFlag:context: and applies it to `LOG_CONTEXT_ALL`.
111
- **/
112
- #if TARGET_OS_IPHONE
113
- - (void)setForegroundColor:(UIColor *)txtColor backgroundColor:(UIColor *)bgColor forFlag:(int)mask;
114
- #elif !defined (COCOAPODS_POD_AVAILABLE_CocoaLumberjack_CLI)
115
- - (void)setForegroundColor:(NSColor *)txtColor backgroundColor:(NSColor *)bgColor forFlag:(int)mask;
116
- #else
117
- - (void)setForegroundColor:(CLIColor *)txtColor backgroundColor:(CLIColor *)bgColor forFlag:(int)mask;
118
- #endif
119
-
120
- /**
121
- * Just like setForegroundColor:backgroundColor:flag, but allows you to specify a particular logging context.
122
- *
123
- * A logging context is often used to identify log messages coming from a 3rd party framework,
124
- * although logging context's can be used for many different functions.
125
- *
126
- * Use LOG_CONTEXT_ALL to set the deafult color for all contexts that have no specific color set defined.
127
- *
128
- * Logging context's are explained in further detail here:
129
- * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/CustomContext
130
- **/
131
- #if TARGET_OS_IPHONE
132
- - (void)setForegroundColor:(UIColor *)txtColor backgroundColor:(UIColor *)bgColor forFlag:(int)mask context:(int)ctxt;
133
- #elif !defined (COCOAPODS_POD_AVAILABLE_CocoaLumberjack_CLI)
134
- - (void)setForegroundColor:(NSColor *)txtColor backgroundColor:(NSColor *)bgColor forFlag:(int)mask context:(int)ctxt;
135
- #else
136
- - (void)setForegroundColor:(CLIColor *)txtColor backgroundColor:(CLIColor *)bgColor forFlag:(int)mask context:(int)ctxt;
137
- #endif
138
-
139
- /**
140
- * Similar to the methods above, but allows you to map DDLogMessage->tag to a particular color profile.
141
- * For example, you could do something like this:
142
- *
143
- * static NSString *const PurpleTag = @"PurpleTag";
144
- *
145
- * #define DDLogPurple(frmt, ...) LOG_OBJC_TAG_MACRO(NO, 0, 0, 0, PurpleTag, frmt, ##__VA_ARGS__)
146
- *
147
- * And then in your applicationDidFinishLaunching, or wherever you configure Lumberjack:
148
- *
149
- * #if TARGET_OS_IPHONE
150
- * UIColor *purple = [UIColor colorWithRed:(64/255.0) green:(0/255.0) blue:(128/255.0) alpha:1.0];
151
- * #else
152
- * NSColor *purple = [NSColor colorWithCalibratedRed:(64/255.0) green:(0/255.0) blue:(128/255.0) alpha:1.0];
153
- *
154
- * Note: For CLI OS X projects that don't link with AppKit use CLIColor objects instead
155
- *
156
- * [[DDTTYLogger sharedInstance] setForegroundColor:purple backgroundColor:nil forTag:PurpleTag];
157
- * [DDLog addLogger:[DDTTYLogger sharedInstance]];
158
- *
159
- * This would essentially give you a straight NSLog replacement that prints in purple:
160
- *
161
- * DDLogPurple(@"I'm a purple log message!");
162
- **/
163
- #if TARGET_OS_IPHONE
164
- - (void)setForegroundColor:(UIColor *)txtColor backgroundColor:(UIColor *)bgColor forTag:(id <NSCopying>)tag;
165
- #elif !defined (COCOAPODS_POD_AVAILABLE_CocoaLumberjack_CLI)
166
- - (void)setForegroundColor:(NSColor *)txtColor backgroundColor:(NSColor *)bgColor forTag:(id <NSCopying>)tag;
167
- #else
168
- - (void)setForegroundColor:(CLIColor *)txtColor backgroundColor:(CLIColor *)bgColor forTag:(id <NSCopying>)tag;
169
- #endif
170
-
171
- /**
172
- * Clearing color profiles.
173
- **/
174
- - (void)clearColorsForFlag:(int)mask;
175
- - (void)clearColorsForFlag:(int)mask context:(int)context;
176
- - (void)clearColorsForTag:(id <NSCopying>)tag;
177
- - (void)clearColorsForAllFlags;
178
- - (void)clearColorsForAllTags;
179
- - (void)clearAllColors;
180
-
181
- @end
@@ -1,1520 +0,0 @@
1
- #import "DDTTYLogger.h"
2
-
3
- #import <unistd.h>
4
- #import <sys/uio.h>
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/CocoaLumberjack/CocoaLumberjack
11
- *
12
- * If you're new to the project you may wish to read the "Getting Started" wiki.
13
- * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
14
- **/
15
-
16
- #if ! __has_feature(objc_arc)
17
- #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
18
- #endif
19
-
20
- // We probably shouldn't be using DDLog() statements within the DDLog implementation.
21
- // But we still want to leave our log statements for any future debugging,
22
- // and to allow other developers to trace the implementation (which is a great learning tool).
23
- //
24
- // So we use primitive logging macros around NSLog.
25
- // We maintain the NS prefix on the macros to be explicit about the fact that we're using NSLog.
26
-
27
- #define LOG_LEVEL 2
28
-
29
- #define NSLogError(frmt, ...) do{ if(LOG_LEVEL >= 1) NSLog((frmt), ##__VA_ARGS__); } while(0)
30
- #define NSLogWarn(frmt, ...) do{ if(LOG_LEVEL >= 2) NSLog((frmt), ##__VA_ARGS__); } while(0)
31
- #define NSLogInfo(frmt, ...) do{ if(LOG_LEVEL >= 3) NSLog((frmt), ##__VA_ARGS__); } while(0)
32
- #define NSLogDebug(frmt, ...) do{ if(LOG_LEVEL >= 4) NSLog((frmt), ##__VA_ARGS__); } while(0)
33
- #define NSLogVerbose(frmt, ...) do{ if(LOG_LEVEL >= 5) NSLog((frmt), ##__VA_ARGS__); } while(0)
34
-
35
- // Xcode does NOT natively support colors in the Xcode debugging console.
36
- // You'll need to install the XcodeColors plugin to see colors in the Xcode console.
37
- // https://github.com/robbiehanson/XcodeColors
38
- //
39
- // The following is documentation from the XcodeColors project:
40
- //
41
- //
42
- // How to apply color formatting to your log statements:
43
- //
44
- // To set the foreground color:
45
- // Insert the ESCAPE_SEQ into your string, followed by "fg124,12,255;" where r=124, g=12, b=255.
46
- //
47
- // To set the background color:
48
- // Insert the ESCAPE_SEQ into your string, followed by "bg12,24,36;" where r=12, g=24, b=36.
49
- //
50
- // To reset the foreground color (to default value):
51
- // Insert the ESCAPE_SEQ into your string, followed by "fg;"
52
- //
53
- // To reset the background color (to default value):
54
- // Insert the ESCAPE_SEQ into your string, followed by "bg;"
55
- //
56
- // To reset the foreground and background color (to default values) in one operation:
57
- // Insert the ESCAPE_SEQ into your string, followed by ";"
58
-
59
- #define XCODE_COLORS_ESCAPE_SEQ "\033["
60
-
61
- #define XCODE_COLORS_RESET_FG XCODE_COLORS_ESCAPE_SEQ "fg;" // Clear any foreground color
62
- #define XCODE_COLORS_RESET_BG XCODE_COLORS_ESCAPE_SEQ "bg;" // Clear any background color
63
- #define XCODE_COLORS_RESET XCODE_COLORS_ESCAPE_SEQ ";" // Clear any foreground or background color
64
-
65
- // Some simple defines to make life easier on ourself
66
-
67
- #if TARGET_OS_IPHONE
68
- #define OSColor UIColor
69
- #define MakeColor(r, g, b) [UIColor colorWithRed:(r/255.0f) green:(g/255.0f) blue:(b/255.0f) alpha:1.0f]
70
- #elif !defined (COCOAPODS_POD_AVAILABLE_CocoaLumberjack_CLI)
71
- #define OSColor NSColor
72
- #define MakeColor(r, g, b) [NSColor colorWithCalibratedRed:(r/255.0f) green:(g/255.0f) blue:(b/255.0f) alpha:1.0f]
73
- #else
74
- #define OSColor CLIColor
75
- #define MakeColor(r, g, b) [CLIColor colorWithCalibratedRed:(r/255.0f) green:(g/255.0f) blue:(b/255.0f) alpha:1.0f]
76
- #endif
77
-
78
- // If running in a shell, not all RGB colors will be supported.
79
- // In this case we automatically map to the closest available color.
80
- // In order to provide this mapping, we have a hard-coded set of the standard RGB values available in the shell.
81
- // However, not every shell is the same, and Apple likes to think different even when it comes to shell colors.
82
- //
83
- // Map to standard Terminal.app colors (1), or
84
- // map to standard xterm colors (0).
85
-
86
- #define MAP_TO_TERMINAL_APP_COLORS 1
87
-
88
-
89
- @interface DDTTYLoggerColorProfile : NSObject {
90
- @public
91
- int mask;
92
- int context;
93
-
94
- uint8_t fg_r;
95
- uint8_t fg_g;
96
- uint8_t fg_b;
97
-
98
- uint8_t bg_r;
99
- uint8_t bg_g;
100
- uint8_t bg_b;
101
-
102
- NSUInteger fgCodeIndex;
103
- NSString *fgCodeRaw;
104
-
105
- NSUInteger bgCodeIndex;
106
- NSString *bgCodeRaw;
107
-
108
- char fgCode[24];
109
- size_t fgCodeLen;
110
-
111
- char bgCode[24];
112
- size_t bgCodeLen;
113
-
114
- char resetCode[8];
115
- size_t resetCodeLen;
116
- }
117
-
118
- - (instancetype)initWithForegroundColor:(OSColor *)fgColor backgroundColor:(OSColor *)bgColor flag:(int)mask context:(int)ctxt;
119
-
120
- @end
121
-
122
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
123
- #pragma mark -
124
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
125
-
126
- @implementation DDTTYLogger
127
-
128
- static BOOL isaColorTTY;
129
- static BOOL isaColor256TTY;
130
- static BOOL isaXcodeColorTTY;
131
-
132
- static NSArray *codes_fg = nil;
133
- static NSArray *codes_bg = nil;
134
- static NSArray *colors = nil;
135
-
136
- static DDTTYLogger *sharedInstance;
137
-
138
- /**
139
- * Initializes the colors array, as well as the codes_fg and codes_bg arrays, for 16 color mode.
140
- *
141
- * This method is used when the application is running from within a shell that only supports 16 color mode.
142
- * This method is not invoked if the application is running within Xcode, or via normal UI app launch.
143
- **/
144
- + (void)initialize_colors_16
145
- {
146
- if (codes_fg || codes_bg || colors) return;
147
-
148
- NSMutableArray *m_codes_fg = [NSMutableArray arrayWithCapacity:16];
149
- NSMutableArray *m_codes_bg = [NSMutableArray arrayWithCapacity:16];
150
- NSMutableArray *m_colors = [NSMutableArray arrayWithCapacity:16];
151
-
152
- // In a standard shell only 16 colors are supported.
153
- //
154
- // More information about ansi escape codes can be found online.
155
- // http://en.wikipedia.org/wiki/ANSI_escape_code
156
-
157
- [m_codes_fg addObject:@"30m"]; // normal - black
158
- [m_codes_fg addObject:@"31m"]; // normal - red
159
- [m_codes_fg addObject:@"32m"]; // normal - green
160
- [m_codes_fg addObject:@"33m"]; // normal - yellow
161
- [m_codes_fg addObject:@"34m"]; // normal - blue
162
- [m_codes_fg addObject:@"35m"]; // normal - magenta
163
- [m_codes_fg addObject:@"36m"]; // normal - cyan
164
- [m_codes_fg addObject:@"37m"]; // normal - gray
165
- [m_codes_fg addObject:@"1;30m"]; // bright - darkgray
166
- [m_codes_fg addObject:@"1;31m"]; // bright - red
167
- [m_codes_fg addObject:@"1;32m"]; // bright - green
168
- [m_codes_fg addObject:@"1;33m"]; // bright - yellow
169
- [m_codes_fg addObject:@"1;34m"]; // bright - blue
170
- [m_codes_fg addObject:@"1;35m"]; // bright - magenta
171
- [m_codes_fg addObject:@"1;36m"]; // bright - cyan
172
- [m_codes_fg addObject:@"1;37m"]; // bright - white
173
-
174
- [m_codes_bg addObject:@"40m"]; // normal - black
175
- [m_codes_bg addObject:@"41m"]; // normal - red
176
- [m_codes_bg addObject:@"42m"]; // normal - green
177
- [m_codes_bg addObject:@"43m"]; // normal - yellow
178
- [m_codes_bg addObject:@"44m"]; // normal - blue
179
- [m_codes_bg addObject:@"45m"]; // normal - magenta
180
- [m_codes_bg addObject:@"46m"]; // normal - cyan
181
- [m_codes_bg addObject:@"47m"]; // normal - gray
182
- [m_codes_bg addObject:@"1;40m"]; // bright - darkgray
183
- [m_codes_bg addObject:@"1;41m"]; // bright - red
184
- [m_codes_bg addObject:@"1;42m"]; // bright - green
185
- [m_codes_bg addObject:@"1;43m"]; // bright - yellow
186
- [m_codes_bg addObject:@"1;44m"]; // bright - blue
187
- [m_codes_bg addObject:@"1;45m"]; // bright - magenta
188
- [m_codes_bg addObject:@"1;46m"]; // bright - cyan
189
- [m_codes_bg addObject:@"1;47m"]; // bright - white
190
-
191
- #if MAP_TO_TERMINAL_APP_COLORS
192
-
193
- // Standard Terminal.app colors:
194
- //
195
- // These are the default colors used by Apple's Terminal.app.
196
-
197
- [m_colors addObject:MakeColor( 0, 0, 0)]; // normal - black
198
- [m_colors addObject:MakeColor(194, 54, 33)]; // normal - red
199
- [m_colors addObject:MakeColor( 37, 188, 36)]; // normal - green
200
- [m_colors addObject:MakeColor(173, 173, 39)]; // normal - yellow
201
- [m_colors addObject:MakeColor( 73, 46, 225)]; // normal - blue
202
- [m_colors addObject:MakeColor(211, 56, 211)]; // normal - magenta
203
- [m_colors addObject:MakeColor( 51, 187, 200)]; // normal - cyan
204
- [m_colors addObject:MakeColor(203, 204, 205)]; // normal - gray
205
- [m_colors addObject:MakeColor(129, 131, 131)]; // bright - darkgray
206
- [m_colors addObject:MakeColor(252, 57, 31)]; // bright - red
207
- [m_colors addObject:MakeColor( 49, 231, 34)]; // bright - green
208
- [m_colors addObject:MakeColor(234, 236, 35)]; // bright - yellow
209
- [m_colors addObject:MakeColor( 88, 51, 255)]; // bright - blue
210
- [m_colors addObject:MakeColor(249, 53, 248)]; // bright - magenta
211
- [m_colors addObject:MakeColor( 20, 240, 240)]; // bright - cyan
212
- [m_colors addObject:MakeColor(233, 235, 235)]; // bright - white
213
-
214
- #else
215
-
216
- // Standard xterm colors:
217
- //
218
- // These are the default colors used by most xterm shells.
219
-
220
- [m_colors addObject:MakeColor( 0, 0, 0)]; // normal - black
221
- [m_colors addObject:MakeColor(205, 0, 0)]; // normal - red
222
- [m_colors addObject:MakeColor( 0, 205, 0)]; // normal - green
223
- [m_colors addObject:MakeColor(205, 205, 0)]; // normal - yellow
224
- [m_colors addObject:MakeColor( 0, 0, 238)]; // normal - blue
225
- [m_colors addObject:MakeColor(205, 0, 205)]; // normal - magenta
226
- [m_colors addObject:MakeColor( 0, 205, 205)]; // normal - cyan
227
- [m_colors addObject:MakeColor(229, 229, 229)]; // normal - gray
228
- [m_colors addObject:MakeColor(127, 127, 127)]; // bright - darkgray
229
- [m_colors addObject:MakeColor(255, 0, 0)]; // bright - red
230
- [m_colors addObject:MakeColor( 0, 255, 0)]; // bright - green
231
- [m_colors addObject:MakeColor(255, 255, 0)]; // bright - yellow
232
- [m_colors addObject:MakeColor( 92, 92, 255)]; // bright - blue
233
- [m_colors addObject:MakeColor(255, 0, 255)]; // bright - magenta
234
- [m_colors addObject:MakeColor( 0, 255, 255)]; // bright - cyan
235
- [m_colors addObject:MakeColor(255, 255, 255)]; // bright - white
236
-
237
- #endif
238
-
239
- codes_fg = [m_codes_fg copy];
240
- codes_bg = [m_codes_bg copy];
241
- colors = [m_colors copy];
242
-
243
- NSAssert([codes_fg count] == [codes_bg count], @"Invalid colors/codes array(s)");
244
- NSAssert([codes_fg count] == [colors count], @"Invalid colors/codes array(s)");
245
- }
246
-
247
- /**
248
- * Initializes the colors array, as well as the codes_fg and codes_bg arrays, for 256 color mode.
249
- *
250
- * This method is used when the application is running from within a shell that supports 256 color mode.
251
- * This method is not invoked if the application is running within Xcode, or via normal UI app launch.
252
- **/
253
- + (void)initialize_colors_256
254
- {
255
- if (codes_fg || codes_bg || colors) return;
256
-
257
- NSMutableArray *m_codes_fg = [NSMutableArray arrayWithCapacity:(256-16)];
258
- NSMutableArray *m_codes_bg = [NSMutableArray arrayWithCapacity:(256-16)];
259
- NSMutableArray *m_colors = [NSMutableArray arrayWithCapacity:(256-16)];
260
-
261
- #if MAP_TO_TERMINAL_APP_COLORS
262
-
263
- // Standard Terminal.app colors:
264
- //
265
- // These are the colors the Terminal.app uses in xterm-256color mode.
266
- // In this mode, the terminal supports 256 different colors, specified by 256 color codes.
267
- //
268
- // The first 16 color codes map to the original 16 color codes supported by the earlier xterm-color mode.
269
- // These are actually configurable, and thus we ignore them for the purposes of mapping,
270
- // as we can't rely on them being constant. They are largely duplicated anyway.
271
- //
272
- // The next 216 color codes are designed to run the spectrum, with several shades of every color.
273
- // While the color codes are standardized, the actual RGB values for each color code is not.
274
- // Apple's Terminal.app uses different RGB values from that of a standard xterm.
275
- // Apple's choices in colors are designed to be a little nicer on the eyes.
276
- //
277
- // The last 24 color codes represent a grayscale.
278
- //
279
- // Unfortunately, unlike the standard xterm color chart,
280
- // Apple's RGB values cannot be calculated using a simple formula (at least not that I know of).
281
- // Also, I don't know of any ways to programmatically query the shell for the RGB values.
282
- // So this big giant color chart had to be made by hand.
283
- //
284
- // More information about ansi escape codes can be found online.
285
- // http://en.wikipedia.org/wiki/ANSI_escape_code
286
-
287
- // Colors
288
-
289
- [m_colors addObject:MakeColor( 47, 49, 49)];
290
- [m_colors addObject:MakeColor( 60, 42, 144)];
291
- [m_colors addObject:MakeColor( 66, 44, 183)];
292
- [m_colors addObject:MakeColor( 73, 46, 222)];
293
- [m_colors addObject:MakeColor( 81, 50, 253)];
294
- [m_colors addObject:MakeColor( 88, 51, 255)];
295
-
296
- [m_colors addObject:MakeColor( 42, 128, 37)];
297
- [m_colors addObject:MakeColor( 42, 127, 128)];
298
- [m_colors addObject:MakeColor( 44, 126, 169)];
299
- [m_colors addObject:MakeColor( 56, 125, 209)];
300
- [m_colors addObject:MakeColor( 59, 124, 245)];
301
- [m_colors addObject:MakeColor( 66, 123, 255)];
302
-
303
- [m_colors addObject:MakeColor( 51, 163, 41)];
304
- [m_colors addObject:MakeColor( 39, 162, 121)];
305
- [m_colors addObject:MakeColor( 42, 161, 162)];
306
- [m_colors addObject:MakeColor( 53, 160, 202)];
307
- [m_colors addObject:MakeColor( 45, 159, 240)];
308
- [m_colors addObject:MakeColor( 58, 158, 255)];
309
-
310
- [m_colors addObject:MakeColor( 31, 196, 37)];
311
- [m_colors addObject:MakeColor( 48, 196, 115)];
312
- [m_colors addObject:MakeColor( 39, 195, 155)];
313
- [m_colors addObject:MakeColor( 49, 195, 195)];
314
- [m_colors addObject:MakeColor( 32, 194, 235)];
315
- [m_colors addObject:MakeColor( 53, 193, 255)];
316
-
317
- [m_colors addObject:MakeColor( 50, 229, 35)];
318
- [m_colors addObject:MakeColor( 40, 229, 109)];
319
- [m_colors addObject:MakeColor( 27, 229, 149)];
320
- [m_colors addObject:MakeColor( 49, 228, 189)];
321
- [m_colors addObject:MakeColor( 33, 228, 228)];
322
- [m_colors addObject:MakeColor( 53, 227, 255)];
323
-
324
- [m_colors addObject:MakeColor( 27, 254, 30)];
325
- [m_colors addObject:MakeColor( 30, 254, 103)];
326
- [m_colors addObject:MakeColor( 45, 254, 143)];
327
- [m_colors addObject:MakeColor( 38, 253, 182)];
328
- [m_colors addObject:MakeColor( 38, 253, 222)];
329
- [m_colors addObject:MakeColor( 42, 253, 252)];
330
-
331
- [m_colors addObject:MakeColor(140, 48, 40)];
332
- [m_colors addObject:MakeColor(136, 51, 136)];
333
- [m_colors addObject:MakeColor(135, 52, 177)];
334
- [m_colors addObject:MakeColor(134, 52, 217)];
335
- [m_colors addObject:MakeColor(135, 56, 248)];
336
- [m_colors addObject:MakeColor(134, 53, 255)];
337
-
338
- [m_colors addObject:MakeColor(125, 125, 38)];
339
- [m_colors addObject:MakeColor(124, 125, 125)];
340
- [m_colors addObject:MakeColor(122, 124, 166)];
341
- [m_colors addObject:MakeColor(123, 124, 207)];
342
- [m_colors addObject:MakeColor(123, 122, 247)];
343
- [m_colors addObject:MakeColor(124, 121, 255)];
344
-
345
- [m_colors addObject:MakeColor(119, 160, 35)];
346
- [m_colors addObject:MakeColor(117, 160, 120)];
347
- [m_colors addObject:MakeColor(117, 160, 160)];
348
- [m_colors addObject:MakeColor(115, 159, 201)];
349
- [m_colors addObject:MakeColor(116, 158, 240)];
350
- [m_colors addObject:MakeColor(117, 157, 255)];
351
-
352
- [m_colors addObject:MakeColor(113, 195, 39)];
353
- [m_colors addObject:MakeColor(110, 194, 114)];
354
- [m_colors addObject:MakeColor(111, 194, 154)];
355
- [m_colors addObject:MakeColor(108, 194, 194)];
356
- [m_colors addObject:MakeColor(109, 193, 234)];
357
- [m_colors addObject:MakeColor(108, 192, 255)];
358
-
359
- [m_colors addObject:MakeColor(105, 228, 30)];
360
- [m_colors addObject:MakeColor(103, 228, 109)];
361
- [m_colors addObject:MakeColor(105, 228, 148)];
362
- [m_colors addObject:MakeColor(100, 227, 188)];
363
- [m_colors addObject:MakeColor( 99, 227, 227)];
364
- [m_colors addObject:MakeColor( 99, 226, 253)];
365
-
366
- [m_colors addObject:MakeColor( 92, 253, 34)];
367
- [m_colors addObject:MakeColor( 96, 253, 103)];
368
- [m_colors addObject:MakeColor( 97, 253, 142)];
369
- [m_colors addObject:MakeColor( 88, 253, 182)];
370
- [m_colors addObject:MakeColor( 93, 253, 221)];
371
- [m_colors addObject:MakeColor( 88, 254, 251)];
372
-
373
- [m_colors addObject:MakeColor(177, 53, 34)];
374
- [m_colors addObject:MakeColor(174, 54, 131)];
375
- [m_colors addObject:MakeColor(172, 55, 172)];
376
- [m_colors addObject:MakeColor(171, 57, 213)];
377
- [m_colors addObject:MakeColor(170, 55, 249)];
378
- [m_colors addObject:MakeColor(170, 57, 255)];
379
-
380
- [m_colors addObject:MakeColor(165, 123, 37)];
381
- [m_colors addObject:MakeColor(163, 123, 123)];
382
- [m_colors addObject:MakeColor(162, 123, 164)];
383
- [m_colors addObject:MakeColor(161, 122, 205)];
384
- [m_colors addObject:MakeColor(161, 121, 241)];
385
- [m_colors addObject:MakeColor(161, 121, 255)];
386
-
387
- [m_colors addObject:MakeColor(158, 159, 33)];
388
- [m_colors addObject:MakeColor(157, 158, 118)];
389
- [m_colors addObject:MakeColor(157, 158, 159)];
390
- [m_colors addObject:MakeColor(155, 157, 199)];
391
- [m_colors addObject:MakeColor(155, 157, 239)];
392
- [m_colors addObject:MakeColor(154, 156, 255)];
393
-
394
- [m_colors addObject:MakeColor(152, 193, 40)];
395
- [m_colors addObject:MakeColor(151, 193, 113)];
396
- [m_colors addObject:MakeColor(150, 193, 153)];
397
- [m_colors addObject:MakeColor(150, 192, 193)];
398
- [m_colors addObject:MakeColor(148, 192, 232)];
399
- [m_colors addObject:MakeColor(149, 191, 253)];
400
-
401
- [m_colors addObject:MakeColor(146, 227, 28)];
402
- [m_colors addObject:MakeColor(144, 227, 108)];
403
- [m_colors addObject:MakeColor(144, 227, 147)];
404
- [m_colors addObject:MakeColor(144, 227, 187)];
405
- [m_colors addObject:MakeColor(142, 226, 227)];
406
- [m_colors addObject:MakeColor(142, 225, 252)];
407
-
408
- [m_colors addObject:MakeColor(138, 253, 36)];
409
- [m_colors addObject:MakeColor(137, 253, 102)];
410
- [m_colors addObject:MakeColor(136, 253, 141)];
411
- [m_colors addObject:MakeColor(138, 254, 181)];
412
- [m_colors addObject:MakeColor(135, 255, 220)];
413
- [m_colors addObject:MakeColor(133, 255, 250)];
414
-
415
- [m_colors addObject:MakeColor(214, 57, 30)];
416
- [m_colors addObject:MakeColor(211, 59, 126)];
417
- [m_colors addObject:MakeColor(209, 57, 168)];
418
- [m_colors addObject:MakeColor(208, 55, 208)];
419
- [m_colors addObject:MakeColor(207, 58, 247)];
420
- [m_colors addObject:MakeColor(206, 61, 255)];
421
-
422
- [m_colors addObject:MakeColor(204, 121, 32)];
423
- [m_colors addObject:MakeColor(202, 121, 121)];
424
- [m_colors addObject:MakeColor(201, 121, 161)];
425
- [m_colors addObject:MakeColor(200, 120, 202)];
426
- [m_colors addObject:MakeColor(200, 120, 241)];
427
- [m_colors addObject:MakeColor(198, 119, 255)];
428
-
429
- [m_colors addObject:MakeColor(198, 157, 37)];
430
- [m_colors addObject:MakeColor(196, 157, 116)];
431
- [m_colors addObject:MakeColor(195, 156, 157)];
432
- [m_colors addObject:MakeColor(195, 156, 197)];
433
- [m_colors addObject:MakeColor(194, 155, 236)];
434
- [m_colors addObject:MakeColor(193, 155, 255)];
435
-
436
- [m_colors addObject:MakeColor(191, 192, 36)];
437
- [m_colors addObject:MakeColor(190, 191, 112)];
438
- [m_colors addObject:MakeColor(189, 191, 152)];
439
- [m_colors addObject:MakeColor(189, 191, 191)];
440
- [m_colors addObject:MakeColor(188, 190, 230)];
441
- [m_colors addObject:MakeColor(187, 190, 253)];
442
-
443
- [m_colors addObject:MakeColor(185, 226, 28)];
444
- [m_colors addObject:MakeColor(184, 226, 106)];
445
- [m_colors addObject:MakeColor(183, 225, 146)];
446
- [m_colors addObject:MakeColor(183, 225, 186)];
447
- [m_colors addObject:MakeColor(182, 225, 225)];
448
- [m_colors addObject:MakeColor(181, 224, 252)];
449
-
450
- [m_colors addObject:MakeColor(178, 255, 35)];
451
- [m_colors addObject:MakeColor(178, 255, 101)];
452
- [m_colors addObject:MakeColor(177, 254, 141)];
453
- [m_colors addObject:MakeColor(176, 254, 180)];
454
- [m_colors addObject:MakeColor(176, 254, 220)];
455
- [m_colors addObject:MakeColor(175, 253, 249)];
456
-
457
- [m_colors addObject:MakeColor(247, 56, 30)];
458
- [m_colors addObject:MakeColor(245, 57, 122)];
459
- [m_colors addObject:MakeColor(243, 59, 163)];
460
- [m_colors addObject:MakeColor(244, 60, 204)];
461
- [m_colors addObject:MakeColor(242, 59, 241)];
462
- [m_colors addObject:MakeColor(240, 55, 255)];
463
-
464
- [m_colors addObject:MakeColor(241, 119, 36)];
465
- [m_colors addObject:MakeColor(240, 120, 118)];
466
- [m_colors addObject:MakeColor(238, 119, 158)];
467
- [m_colors addObject:MakeColor(237, 119, 199)];
468
- [m_colors addObject:MakeColor(237, 118, 238)];
469
- [m_colors addObject:MakeColor(236, 118, 255)];
470
-
471
- [m_colors addObject:MakeColor(235, 154, 36)];
472
- [m_colors addObject:MakeColor(235, 154, 114)];
473
- [m_colors addObject:MakeColor(234, 154, 154)];
474
- [m_colors addObject:MakeColor(232, 154, 194)];
475
- [m_colors addObject:MakeColor(232, 153, 234)];
476
- [m_colors addObject:MakeColor(232, 153, 255)];
477
-
478
- [m_colors addObject:MakeColor(230, 190, 30)];
479
- [m_colors addObject:MakeColor(229, 189, 110)];
480
- [m_colors addObject:MakeColor(228, 189, 150)];
481
- [m_colors addObject:MakeColor(227, 189, 190)];
482
- [m_colors addObject:MakeColor(227, 189, 229)];
483
- [m_colors addObject:MakeColor(226, 188, 255)];
484
-
485
- [m_colors addObject:MakeColor(224, 224, 35)];
486
- [m_colors addObject:MakeColor(223, 224, 105)];
487
- [m_colors addObject:MakeColor(222, 224, 144)];
488
- [m_colors addObject:MakeColor(222, 223, 184)];
489
- [m_colors addObject:MakeColor(222, 223, 224)];
490
- [m_colors addObject:MakeColor(220, 223, 253)];
491
-
492
- [m_colors addObject:MakeColor(217, 253, 28)];
493
- [m_colors addObject:MakeColor(217, 253, 99)];
494
- [m_colors addObject:MakeColor(216, 252, 139)];
495
- [m_colors addObject:MakeColor(216, 252, 179)];
496
- [m_colors addObject:MakeColor(215, 252, 218)];
497
- [m_colors addObject:MakeColor(215, 251, 250)];
498
-
499
- [m_colors addObject:MakeColor(255, 61, 30)];
500
- [m_colors addObject:MakeColor(255, 60, 118)];
501
- [m_colors addObject:MakeColor(255, 58, 159)];
502
- [m_colors addObject:MakeColor(255, 56, 199)];
503
- [m_colors addObject:MakeColor(255, 55, 238)];
504
- [m_colors addObject:MakeColor(255, 59, 255)];
505
-
506
- [m_colors addObject:MakeColor(255, 117, 29)];
507
- [m_colors addObject:MakeColor(255, 117, 115)];
508
- [m_colors addObject:MakeColor(255, 117, 155)];
509
- [m_colors addObject:MakeColor(255, 117, 195)];
510
- [m_colors addObject:MakeColor(255, 116, 235)];
511
- [m_colors addObject:MakeColor(254, 116, 255)];
512
-
513
- [m_colors addObject:MakeColor(255, 152, 27)];
514
- [m_colors addObject:MakeColor(255, 152, 111)];
515
- [m_colors addObject:MakeColor(254, 152, 152)];
516
- [m_colors addObject:MakeColor(255, 152, 192)];
517
- [m_colors addObject:MakeColor(254, 151, 231)];
518
- [m_colors addObject:MakeColor(253, 151, 253)];
519
-
520
- [m_colors addObject:MakeColor(255, 187, 33)];
521
- [m_colors addObject:MakeColor(253, 187, 107)];
522
- [m_colors addObject:MakeColor(252, 187, 148)];
523
- [m_colors addObject:MakeColor(253, 187, 187)];
524
- [m_colors addObject:MakeColor(254, 187, 227)];
525
- [m_colors addObject:MakeColor(252, 186, 252)];
526
-
527
- [m_colors addObject:MakeColor(252, 222, 34)];
528
- [m_colors addObject:MakeColor(251, 222, 103)];
529
- [m_colors addObject:MakeColor(251, 222, 143)];
530
- [m_colors addObject:MakeColor(250, 222, 182)];
531
- [m_colors addObject:MakeColor(251, 221, 222)];
532
- [m_colors addObject:MakeColor(252, 221, 252)];
533
-
534
- [m_colors addObject:MakeColor(251, 252, 15)];
535
- [m_colors addObject:MakeColor(251, 252, 97)];
536
- [m_colors addObject:MakeColor(249, 252, 137)];
537
- [m_colors addObject:MakeColor(247, 252, 177)];
538
- [m_colors addObject:MakeColor(247, 253, 217)];
539
- [m_colors addObject:MakeColor(254, 255, 255)];
540
-
541
- // Grayscale
542
-
543
- [m_colors addObject:MakeColor( 52, 53, 53)];
544
- [m_colors addObject:MakeColor( 57, 58, 59)];
545
- [m_colors addObject:MakeColor( 66, 67, 67)];
546
- [m_colors addObject:MakeColor( 75, 76, 76)];
547
- [m_colors addObject:MakeColor( 83, 85, 85)];
548
- [m_colors addObject:MakeColor( 92, 93, 94)];
549
-
550
- [m_colors addObject:MakeColor(101, 102, 102)];
551
- [m_colors addObject:MakeColor(109, 111, 111)];
552
- [m_colors addObject:MakeColor(118, 119, 119)];
553
- [m_colors addObject:MakeColor(126, 127, 128)];
554
- [m_colors addObject:MakeColor(134, 136, 136)];
555
- [m_colors addObject:MakeColor(143, 144, 145)];
556
-
557
- [m_colors addObject:MakeColor(151, 152, 153)];
558
- [m_colors addObject:MakeColor(159, 161, 161)];
559
- [m_colors addObject:MakeColor(167, 169, 169)];
560
- [m_colors addObject:MakeColor(176, 177, 177)];
561
- [m_colors addObject:MakeColor(184, 185, 186)];
562
- [m_colors addObject:MakeColor(192, 193, 194)];
563
-
564
- [m_colors addObject:MakeColor(200, 201, 202)];
565
- [m_colors addObject:MakeColor(208, 209, 210)];
566
- [m_colors addObject:MakeColor(216, 218, 218)];
567
- [m_colors addObject:MakeColor(224, 226, 226)];
568
- [m_colors addObject:MakeColor(232, 234, 234)];
569
- [m_colors addObject:MakeColor(240, 242, 242)];
570
-
571
- // Color codes
572
-
573
- int index = 16;
574
-
575
- while (index < 256)
576
- {
577
- [m_codes_fg addObject:[NSString stringWithFormat:@"38;5;%dm", index]];
578
- [m_codes_bg addObject:[NSString stringWithFormat:@"48;5;%dm", index]];
579
-
580
- index++;
581
- }
582
-
583
- #else
584
-
585
- // Standard xterm colors:
586
- //
587
- // These are the colors xterm shells use in xterm-256color mode.
588
- // In this mode, the shell supports 256 different colors, specified by 256 color codes.
589
- //
590
- // The first 16 color codes map to the original 16 color codes supported by the earlier xterm-color mode.
591
- // These are generally configurable, and thus we ignore them for the purposes of mapping,
592
- // as we can't rely on them being constant. They are largely duplicated anyway.
593
- //
594
- // The next 216 color codes are designed to run the spectrum, with several shades of every color.
595
- // The last 24 color codes represent a grayscale.
596
- //
597
- // While the color codes are standardized, the actual RGB values for each color code is not.
598
- // However most standard xterms follow a well known color chart,
599
- // which can easily be calculated using the simple formula below.
600
- //
601
- // More information about ansi escape codes can be found online.
602
- // http://en.wikipedia.org/wiki/ANSI_escape_code
603
-
604
- int index = 16;
605
-
606
- int r; // red
607
- int g; // green
608
- int b; // blue
609
-
610
- int ri; // r increment
611
- int gi; // g increment
612
- int bi; // b increment
613
-
614
- // Calculate xterm colors (using standard algorithm)
615
-
616
- int r = 0;
617
- int g = 0;
618
- int b = 0;
619
-
620
- for (ri = 0; ri < 6; ri++)
621
- {
622
- r = (ri == 0) ? 0 : 95 + (40 * (ri - 1));
623
-
624
- for (gi = 0; gi < 6; gi++)
625
- {
626
- g = (gi == 0) ? 0 : 95 + (40 * (gi - 1));
627
-
628
- for (bi = 0; bi < 6; bi++)
629
- {
630
- b = (bi == 0) ? 0 : 95 + (40 * (bi - 1));
631
-
632
- [m_codes_fg addObject:[NSString stringWithFormat:@"38;5;%dm", index]];
633
- [m_codes_bg addObject:[NSString stringWithFormat:@"48;5;%dm", index]];
634
- [m_colors addObject:MakeColor(r, g, b)];
635
-
636
- index++;
637
- }
638
- }
639
- }
640
-
641
- // Calculate xterm grayscale (using standard algorithm)
642
-
643
- r = 8;
644
- g = 8;
645
- b = 8;
646
-
647
- while (index < 256)
648
- {
649
- [m_codes_fg addObject:[NSString stringWithFormat:@"38;5;%dm", index]];
650
- [m_codes_bg addObject:[NSString stringWithFormat:@"48;5;%dm", index]];
651
- [m_colors addObject:MakeColor(r, g, b)];
652
-
653
- r += 10;
654
- g += 10;
655
- b += 10;
656
-
657
- index++;
658
- }
659
-
660
- #endif
661
-
662
- codes_fg = [m_codes_fg copy];
663
- codes_bg = [m_codes_bg copy];
664
- colors = [m_colors copy];
665
-
666
- NSAssert([codes_fg count] == [codes_bg count], @"Invalid colors/codes array(s)");
667
- NSAssert([codes_fg count] == [colors count], @"Invalid colors/codes array(s)");
668
- }
669
-
670
- + (void)getRed:(CGFloat *)rPtr green:(CGFloat *)gPtr blue:(CGFloat *)bPtr fromColor:(OSColor *)color
671
- {
672
- #if TARGET_OS_IPHONE
673
-
674
- // iOS
675
-
676
- BOOL done = NO;
677
-
678
- if ([color respondsToSelector:@selector(getRed:green:blue:alpha:)])
679
- {
680
- done = [color getRed:rPtr green:gPtr blue:bPtr alpha:NULL];
681
- }
682
-
683
- if (!done)
684
- {
685
- // The method getRed:green:blue:alpha: was only available starting iOS 5.
686
- // So in iOS 4 and earlier, we have to jump through hoops.
687
-
688
- CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB();
689
-
690
- unsigned char pixel[4];
691
- CGContextRef context = CGBitmapContextCreate(&pixel, 1, 1, 8, 4, rgbColorSpace, kCGBitmapAlphaInfoMask & kCGImageAlphaNoneSkipLast);
692
-
693
- CGContextSetFillColorWithColor(context, [color CGColor]);
694
- CGContextFillRect(context, CGRectMake(0, 0, 1, 1));
695
-
696
- if (rPtr) { *rPtr = pixel[0] / 255.0f; }
697
- if (gPtr) { *gPtr = pixel[1] / 255.0f; }
698
- if (bPtr) { *bPtr = pixel[2] / 255.0f; }
699
-
700
- CGContextRelease(context);
701
- CGColorSpaceRelease(rgbColorSpace);
702
- }
703
-
704
- #elif !defined (COCOAPODS_POD_AVAILABLE_CocoaLumberjack_CLI)
705
-
706
- // OS X with AppKit
707
-
708
- NSColor *safeColor = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
709
-
710
- [safeColor getRed:rPtr green:gPtr blue:bPtr alpha:NULL];
711
-
712
- #else
713
-
714
- // OS X without AppKit
715
-
716
- [color getRed:rPtr green:gPtr blue:bPtr alpha:NULL];
717
-
718
- #endif
719
- }
720
-
721
- /**
722
- * Maps the given color to the closest available color supported by the shell.
723
- * The shell may support 256 colors, or only 16.
724
- *
725
- * This method loops through the known supported color set, and calculates the closest color.
726
- * The array index of that color, within the colors array, is then returned.
727
- * This array index may also be used as the index within the codes_fg and codes_bg arrays.
728
- **/
729
- + (NSUInteger)codeIndexForColor:(OSColor *)inColor
730
- {
731
- CGFloat inR, inG, inB;
732
- [self getRed:&inR green:&inG blue:&inB fromColor:inColor];
733
-
734
- NSUInteger bestIndex = 0;
735
- CGFloat lowestDistance = 100.0f;
736
-
737
- NSUInteger i = 0;
738
- for (OSColor *color in colors)
739
- {
740
- // Calculate Euclidean distance (lower value means closer to given color)
741
-
742
- CGFloat r, g, b;
743
- [self getRed:&r green:&g blue:&b fromColor:color];
744
-
745
- #if CGFLOAT_IS_DOUBLE
746
- CGFloat distance = sqrt(pow(r-inR, 2.0) + pow(g-inG, 2.0) + pow(b-inB, 2.0));
747
- #else
748
- CGFloat distance = sqrtf(powf(r-inR, 2.0f) + powf(g-inG, 2.0f) + powf(b-inB, 2.0f));
749
- #endif
750
-
751
- NSLogVerbose(@"DDTTYLogger: %3lu : %.3f,%.3f,%.3f & %.3f,%.3f,%.3f = %.6f",
752
- (unsigned long)i, inR, inG, inB, r, g, b, distance);
753
-
754
- if (distance < lowestDistance)
755
- {
756
- bestIndex = i;
757
- lowestDistance = distance;
758
-
759
- NSLogVerbose(@"DDTTYLogger: New best index = %lu", (unsigned long)bestIndex);
760
- }
761
-
762
- i++;
763
- }
764
-
765
- return bestIndex;
766
- }
767
-
768
- /**
769
- * The runtime sends initialize to each class in a program exactly one time just before the class,
770
- * or any class that inherits from it, is sent its first message from within the program. (Thus the
771
- * method may never be invoked if the class is not used.) The runtime sends the initialize message to
772
- * classes in a thread-safe manner. Superclasses receive this message before their subclasses.
773
- *
774
- * This method may also be called directly (assumably by accident), hence the safety mechanism.
775
- **/
776
- + (void)initialize
777
- {
778
- static BOOL initialized = NO;
779
- if (!initialized)
780
- {
781
- initialized = YES;
782
-
783
- char *term = getenv("TERM");
784
- if (term)
785
- {
786
- if (strcasestr(term, "color") != NULL)
787
- {
788
- isaColorTTY = YES;
789
- isaColor256TTY = (strcasestr(term, "256") != NULL);
790
-
791
- if (isaColor256TTY)
792
- [self initialize_colors_256];
793
- else
794
- [self initialize_colors_16];
795
- }
796
- }
797
- else
798
- {
799
- // Xcode does NOT natively support colors in the Xcode debugging console.
800
- // You'll need to install the XcodeColors plugin to see colors in the Xcode console.
801
- //
802
- // PS - Please read the header file before diving into the source code.
803
-
804
- char *xcode_colors = getenv("XcodeColors");
805
- if (xcode_colors && (strcmp(xcode_colors, "YES") == 0))
806
- {
807
- isaXcodeColorTTY = YES;
808
- }
809
- }
810
-
811
- NSLogInfo(@"DDTTYLogger: isaColorTTY = %@", (isaColorTTY ? @"YES" : @"NO"));
812
- NSLogInfo(@"DDTTYLogger: isaColor256TTY: %@", (isaColor256TTY ? @"YES" : @"NO"));
813
- NSLogInfo(@"DDTTYLogger: isaXcodeColorTTY: %@", (isaXcodeColorTTY ? @"YES" : @"NO"));
814
-
815
- sharedInstance = [[[self class] alloc] init];
816
- }
817
- }
818
-
819
- + (instancetype)sharedInstance
820
- {
821
- return sharedInstance;
822
- }
823
-
824
- - (id)init
825
- {
826
- if (sharedInstance != nil)
827
- {
828
- return nil;
829
- }
830
-
831
- if ((self = [super init]))
832
- {
833
- calendar = [NSCalendar autoupdatingCurrentCalendar];
834
-
835
- calendarUnitFlags = 0;
836
- calendarUnitFlags |= NSYearCalendarUnit;
837
- calendarUnitFlags |= NSMonthCalendarUnit;
838
- calendarUnitFlags |= NSDayCalendarUnit;
839
- calendarUnitFlags |= NSHourCalendarUnit;
840
- calendarUnitFlags |= NSMinuteCalendarUnit;
841
- calendarUnitFlags |= NSSecondCalendarUnit;
842
-
843
- // Initialze 'app' variable (char *)
844
-
845
- appName = [[NSProcessInfo processInfo] processName];
846
-
847
- appLen = [appName lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
848
- if (appLen == 0) {
849
- appName = @"<UnnamedApp>";
850
- appLen = [appName lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
851
- }
852
- app = (char *)malloc(appLen + 1);
853
- if (app == NULL) return nil;
854
-
855
- BOOL processedAppName = [appName getCString:app maxLength:(appLen+1) encoding:NSUTF8StringEncoding];
856
- if (NO == processedAppName) return nil;
857
-
858
- // Initialize 'pid' variable (char *)
859
-
860
- processID = [NSString stringWithFormat:@"%i", (int)getpid()];
861
-
862
- pidLen = [processID lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
863
- pid = (char *)malloc(pidLen + 1);
864
- if (pid == NULL) return nil;
865
-
866
- BOOL processedID = [processID getCString:pid maxLength:(pidLen+1) encoding:NSUTF8StringEncoding];
867
- if (NO == processedID) return nil;
868
-
869
- // Initialize color stuff
870
-
871
- colorsEnabled = NO;
872
- colorProfilesArray = [[NSMutableArray alloc] initWithCapacity:8];
873
- colorProfilesDict = [[NSMutableDictionary alloc] initWithCapacity:8];
874
- }
875
- return self;
876
- }
877
-
878
- - (void)loadDefaultColorProfiles
879
- {
880
- [self setForegroundColor:MakeColor(214, 57, 30) backgroundColor:nil forFlag:LOG_FLAG_ERROR];
881
- [self setForegroundColor:MakeColor(204, 121, 32) backgroundColor:nil forFlag:LOG_FLAG_WARN];
882
- }
883
-
884
- - (BOOL)colorsEnabled
885
- {
886
- // The design of this method is taken from the DDAbstractLogger implementation.
887
- // For extensive documentation please refer to the DDAbstractLogger implementation.
888
-
889
- // Note: The internal implementation MUST access the colorsEnabled variable directly,
890
- // This method is designed explicitly for external access.
891
- //
892
- // Using "self." syntax to go through this method will cause immediate deadlock.
893
- // This is the intended result. Fix it by accessing the ivar directly.
894
- // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
895
-
896
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
897
- NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
898
-
899
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
900
-
901
- __block BOOL result;
902
-
903
- dispatch_sync(globalLoggingQueue, ^{
904
- dispatch_sync(loggerQueue, ^{
905
- result = colorsEnabled;
906
- });
907
- });
908
-
909
- return result;
910
- }
911
-
912
- - (void)setColorsEnabled:(BOOL)newColorsEnabled
913
- {
914
- dispatch_block_t block = ^{ @autoreleasepool {
915
-
916
- colorsEnabled = newColorsEnabled;
917
-
918
- if ([colorProfilesArray count] == 0) {
919
- [self loadDefaultColorProfiles];
920
- }
921
- }};
922
-
923
- // The design of this method is taken from the DDAbstractLogger implementation.
924
- // For extensive documentation please refer to the DDAbstractLogger implementation.
925
-
926
- // Note: The internal implementation MUST access the colorsEnabled variable directly,
927
- // This method is designed explicitly for external access.
928
- //
929
- // Using "self." syntax to go through this method will cause immediate deadlock.
930
- // This is the intended result. Fix it by accessing the ivar directly.
931
- // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
932
-
933
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
934
- NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
935
-
936
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
937
-
938
- dispatch_async(globalLoggingQueue, ^{
939
- dispatch_async(loggerQueue, block);
940
- });
941
- }
942
-
943
- - (void)setForegroundColor:(OSColor *)txtColor backgroundColor:(OSColor *)bgColor forFlag:(int)mask
944
- {
945
- [self setForegroundColor:txtColor backgroundColor:bgColor forFlag:mask context:LOG_CONTEXT_ALL];
946
- }
947
-
948
- - (void)setForegroundColor:(OSColor *)txtColor backgroundColor:(OSColor *)bgColor forFlag:(int)mask context:(int)ctxt
949
- {
950
- dispatch_block_t block = ^{ @autoreleasepool {
951
-
952
- DDTTYLoggerColorProfile *newColorProfile =
953
- [[DDTTYLoggerColorProfile alloc] initWithForegroundColor:txtColor
954
- backgroundColor:bgColor
955
- flag:mask
956
- context:ctxt];
957
-
958
- NSLogInfo(@"DDTTYLogger: newColorProfile: %@", newColorProfile);
959
-
960
- NSUInteger i = 0;
961
- for (DDTTYLoggerColorProfile *colorProfile in colorProfilesArray)
962
- {
963
- if ((colorProfile->mask == mask) && (colorProfile->context == ctxt))
964
- {
965
- break;
966
- }
967
-
968
- i++;
969
- }
970
-
971
- if (i < [colorProfilesArray count])
972
- [colorProfilesArray replaceObjectAtIndex:i withObject:newColorProfile];
973
- else
974
- [colorProfilesArray addObject:newColorProfile];
975
- }};
976
-
977
- // The design of the setter logic below is taken from the DDAbstractLogger implementation.
978
- // For documentation please refer to the DDAbstractLogger implementation.
979
-
980
- if ([self isOnInternalLoggerQueue])
981
- {
982
- block();
983
- }
984
- else
985
- {
986
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
987
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
988
-
989
- dispatch_async(globalLoggingQueue, ^{
990
- dispatch_async(loggerQueue, block);
991
- });
992
- }
993
- }
994
-
995
- - (void)setForegroundColor:(OSColor *)txtColor backgroundColor:(OSColor *)bgColor forTag:(id <NSCopying>)tag
996
- {
997
- NSAssert([(id <NSObject>)tag conformsToProtocol:@protocol(NSCopying)], @"Invalid tag");
998
-
999
- dispatch_block_t block = ^{ @autoreleasepool {
1000
-
1001
- DDTTYLoggerColorProfile *newColorProfile =
1002
- [[DDTTYLoggerColorProfile alloc] initWithForegroundColor:txtColor
1003
- backgroundColor:bgColor
1004
- flag:0
1005
- context:0];
1006
-
1007
- NSLogInfo(@"DDTTYLogger: newColorProfile: %@", newColorProfile);
1008
-
1009
- [colorProfilesDict setObject:newColorProfile forKey:tag];
1010
- }};
1011
-
1012
- // The design of the setter logic below is taken from the DDAbstractLogger implementation.
1013
- // For documentation please refer to the DDAbstractLogger implementation.
1014
-
1015
- if ([self isOnInternalLoggerQueue])
1016
- {
1017
- block();
1018
- }
1019
- else
1020
- {
1021
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
1022
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
1023
-
1024
- dispatch_async(globalLoggingQueue, ^{
1025
- dispatch_async(loggerQueue, block);
1026
- });
1027
- }
1028
- }
1029
-
1030
- - (void)clearColorsForFlag:(int)mask
1031
- {
1032
- [self clearColorsForFlag:mask context:0];
1033
- }
1034
-
1035
- - (void)clearColorsForFlag:(int)mask context:(int)context
1036
- {
1037
- dispatch_block_t block = ^{ @autoreleasepool {
1038
-
1039
- NSUInteger i = 0;
1040
- for (DDTTYLoggerColorProfile *colorProfile in colorProfilesArray)
1041
- {
1042
- if ((colorProfile->mask == mask) && (colorProfile->context == context))
1043
- {
1044
- break;
1045
- }
1046
-
1047
- i++;
1048
- }
1049
-
1050
- if (i < [colorProfilesArray count])
1051
- {
1052
- [colorProfilesArray removeObjectAtIndex:i];
1053
- }
1054
- }};
1055
-
1056
- // The design of the setter logic below is taken from the DDAbstractLogger implementation.
1057
- // For documentation please refer to the DDAbstractLogger implementation.
1058
-
1059
- if ([self isOnInternalLoggerQueue])
1060
- {
1061
- block();
1062
- }
1063
- else
1064
- {
1065
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
1066
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
1067
-
1068
- dispatch_async(globalLoggingQueue, ^{
1069
- dispatch_async(loggerQueue, block);
1070
- });
1071
- }
1072
- }
1073
-
1074
- - (void)clearColorsForTag:(id <NSCopying>)tag
1075
- {
1076
- NSAssert([(id <NSObject>)tag conformsToProtocol:@protocol(NSCopying)], @"Invalid tag");
1077
-
1078
- dispatch_block_t block = ^{ @autoreleasepool {
1079
-
1080
- [colorProfilesDict removeObjectForKey:tag];
1081
- }};
1082
-
1083
- // The design of the setter logic below is taken from the DDAbstractLogger implementation.
1084
- // For documentation please refer to the DDAbstractLogger implementation.
1085
-
1086
- if ([self isOnInternalLoggerQueue])
1087
- {
1088
- block();
1089
- }
1090
- else
1091
- {
1092
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
1093
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
1094
-
1095
- dispatch_async(globalLoggingQueue, ^{
1096
- dispatch_async(loggerQueue, block);
1097
- });
1098
- }
1099
- }
1100
-
1101
- - (void)clearColorsForAllFlags
1102
- {
1103
- dispatch_block_t block = ^{ @autoreleasepool {
1104
-
1105
- [colorProfilesArray removeAllObjects];
1106
- }};
1107
-
1108
- // The design of the setter logic below is taken from the DDAbstractLogger implementation.
1109
- // For documentation please refer to the DDAbstractLogger implementation.
1110
-
1111
- if ([self isOnInternalLoggerQueue])
1112
- {
1113
- block();
1114
- }
1115
- else
1116
- {
1117
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
1118
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
1119
-
1120
- dispatch_async(globalLoggingQueue, ^{
1121
- dispatch_async(loggerQueue, block);
1122
- });
1123
- }
1124
- }
1125
-
1126
- - (void)clearColorsForAllTags
1127
- {
1128
- dispatch_block_t block = ^{ @autoreleasepool {
1129
-
1130
- [colorProfilesDict removeAllObjects];
1131
- }};
1132
-
1133
- // The design of the setter logic below is taken from the DDAbstractLogger implementation.
1134
- // For documentation please refer to the DDAbstractLogger implementation.
1135
-
1136
- if ([self isOnInternalLoggerQueue])
1137
- {
1138
- block();
1139
- }
1140
- else
1141
- {
1142
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
1143
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
1144
-
1145
- dispatch_async(globalLoggingQueue, ^{
1146
- dispatch_async(loggerQueue, block);
1147
- });
1148
- }
1149
- }
1150
-
1151
- - (void)clearAllColors
1152
- {
1153
- dispatch_block_t block = ^{ @autoreleasepool {
1154
-
1155
- [colorProfilesArray removeAllObjects];
1156
- [colorProfilesDict removeAllObjects];
1157
- }};
1158
-
1159
- // The design of the setter logic below is taken from the DDAbstractLogger implementation.
1160
- // For documentation please refer to the DDAbstractLogger implementation.
1161
-
1162
- if ([self isOnInternalLoggerQueue])
1163
- {
1164
- block();
1165
- }
1166
- else
1167
- {
1168
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
1169
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
1170
-
1171
- dispatch_async(globalLoggingQueue, ^{
1172
- dispatch_async(loggerQueue, block);
1173
- });
1174
- }
1175
- }
1176
-
1177
- - (void)logMessage:(DDLogMessage *)logMessage
1178
- {
1179
- NSString *logMsg = logMessage->logMsg;
1180
- BOOL isFormatted = NO;
1181
-
1182
- if (formatter)
1183
- {
1184
- logMsg = [formatter formatLogMessage:logMessage];
1185
- isFormatted = logMsg != logMessage->logMsg;
1186
- }
1187
-
1188
- if (logMsg)
1189
- {
1190
- // Search for a color profile associated with the log message
1191
-
1192
- DDTTYLoggerColorProfile *colorProfile = nil;
1193
-
1194
- if (colorsEnabled)
1195
- {
1196
- if (logMessage->tag)
1197
- {
1198
- colorProfile = [colorProfilesDict objectForKey:logMessage->tag];
1199
- }
1200
- if (colorProfile == nil)
1201
- {
1202
- for (DDTTYLoggerColorProfile *cp in colorProfilesArray)
1203
- {
1204
- if (logMessage->logFlag & cp->mask)
1205
- {
1206
- // Color profile set for this context?
1207
- if (logMessage->logContext == cp->context)
1208
- {
1209
- colorProfile = cp;
1210
-
1211
- // Stop searching
1212
- break;
1213
- }
1214
-
1215
- // Check if LOG_CONTEXT_ALL was specified as a default color for this flag
1216
- if (cp->context == LOG_CONTEXT_ALL)
1217
- {
1218
- colorProfile = cp;
1219
-
1220
- // We don't break to keep searching for more specific color profiles for the context
1221
- }
1222
- }
1223
- }
1224
- }
1225
- }
1226
-
1227
- // Convert log message to C string.
1228
- //
1229
- // We use the stack instead of the heap for speed if possible.
1230
- // But we're extra cautious to avoid a stack overflow.
1231
-
1232
- NSUInteger msgLen = [logMsg lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
1233
- const BOOL useStack = msgLen < (1024 * 4);
1234
-
1235
- char msgStack[useStack ? (msgLen + 1) : 1]; // Analyzer doesn't like zero-size array, hence the 1
1236
- char *msg = useStack ? msgStack : (char *)malloc(msgLen + 1);
1237
- if (msg == NULL) return;
1238
-
1239
- BOOL logMsgEnc = [logMsg getCString:msg maxLength:(msgLen + 1) encoding:NSUTF8StringEncoding];
1240
- if (!logMsgEnc)
1241
- {
1242
- if (!useStack && msg != NULL) free(msg);
1243
- return;
1244
- }
1245
-
1246
- // Write the log message to STDERR
1247
-
1248
- if (isFormatted)
1249
- {
1250
- // The log message has already been formatted.
1251
-
1252
- struct iovec v[5];
1253
-
1254
- if (colorProfile)
1255
- {
1256
- v[0].iov_base = colorProfile->fgCode;
1257
- v[0].iov_len = colorProfile->fgCodeLen;
1258
-
1259
- v[1].iov_base = colorProfile->bgCode;
1260
- v[1].iov_len = colorProfile->bgCodeLen;
1261
-
1262
- v[4].iov_base = colorProfile->resetCode;
1263
- v[4].iov_len = colorProfile->resetCodeLen;
1264
- }
1265
- else
1266
- {
1267
- v[0].iov_base = "";
1268
- v[0].iov_len = 0;
1269
-
1270
- v[1].iov_base = "";
1271
- v[1].iov_len = 0;
1272
-
1273
- v[4].iov_base = "";
1274
- v[4].iov_len = 0;
1275
- }
1276
-
1277
- v[2].iov_base = (char *)msg;
1278
- v[2].iov_len = msgLen;
1279
-
1280
- v[3].iov_base = "\n";
1281
- v[3].iov_len = (msg[msgLen] == '\n') ? 0 : 1;
1282
-
1283
- writev(STDERR_FILENO, v, 5);
1284
- }
1285
- else
1286
- {
1287
- // The log message is unformatted, so apply standard NSLog style formatting.
1288
-
1289
- int len;
1290
-
1291
- // Calculate timestamp.
1292
- // The technique below is faster than using NSDateFormatter.
1293
-
1294
- NSDateComponents *components = [calendar components:calendarUnitFlags fromDate:logMessage->timestamp];
1295
-
1296
- NSTimeInterval epoch = [logMessage->timestamp timeIntervalSinceReferenceDate];
1297
- int milliseconds = (int)((epoch - floor(epoch)) * 1000);
1298
-
1299
- char ts[24];
1300
- len = snprintf(ts, 24, "%04ld-%02ld-%02ld %02ld:%02ld:%02ld:%03d", // yyyy-MM-dd HH:mm:ss:SSS
1301
- (long)components.year,
1302
- (long)components.month,
1303
- (long)components.day,
1304
- (long)components.hour,
1305
- (long)components.minute,
1306
- (long)components.second, milliseconds);
1307
-
1308
- size_t tsLen = MIN(24-1, len);
1309
-
1310
- // Calculate thread ID
1311
- //
1312
- // How many characters do we need for the thread id?
1313
- // logMessage->machThreadID is of type mach_port_t, which is an unsigned int.
1314
- //
1315
- // 1 hex char = 4 bits
1316
- // 8 hex chars for 32 bit, plus ending '\0' = 9
1317
-
1318
- char tid[9];
1319
- len = snprintf(tid, 9, "%x", logMessage->machThreadID);
1320
-
1321
- size_t tidLen = MIN(9-1, len);
1322
-
1323
- // Here is our format: "%s %s[%i:%s] %s", timestamp, appName, processID, threadID, logMsg
1324
-
1325
- struct iovec v[13];
1326
-
1327
- if (colorProfile)
1328
- {
1329
- v[0].iov_base = colorProfile->fgCode;
1330
- v[0].iov_len = colorProfile->fgCodeLen;
1331
-
1332
- v[1].iov_base = colorProfile->bgCode;
1333
- v[1].iov_len = colorProfile->bgCodeLen;
1334
-
1335
- v[12].iov_base = colorProfile->resetCode;
1336
- v[12].iov_len = colorProfile->resetCodeLen;
1337
- }
1338
- else
1339
- {
1340
- v[0].iov_base = "";
1341
- v[0].iov_len = 0;
1342
-
1343
- v[1].iov_base = "";
1344
- v[1].iov_len = 0;
1345
-
1346
- v[12].iov_base = "";
1347
- v[12].iov_len = 0;
1348
- }
1349
-
1350
- v[2].iov_base = ts;
1351
- v[2].iov_len = tsLen;
1352
-
1353
- v[3].iov_base = " ";
1354
- v[3].iov_len = 1;
1355
-
1356
- v[4].iov_base = app;
1357
- v[4].iov_len = appLen;
1358
-
1359
- v[5].iov_base = "[";
1360
- v[5].iov_len = 1;
1361
-
1362
- v[6].iov_base = pid;
1363
- v[6].iov_len = pidLen;
1364
-
1365
- v[7].iov_base = ":";
1366
- v[7].iov_len = 1;
1367
-
1368
- v[8].iov_base = tid;
1369
- v[8].iov_len = MIN((size_t)8, tidLen); // snprintf doesn't return what you might think
1370
-
1371
- v[9].iov_base = "] ";
1372
- v[9].iov_len = 2;
1373
-
1374
- v[10].iov_base = (char *)msg;
1375
- v[10].iov_len = msgLen;
1376
-
1377
- v[11].iov_base = "\n";
1378
- v[11].iov_len = (msg[msgLen] == '\n') ? 0 : 1;
1379
-
1380
- writev(STDERR_FILENO, v, 13);
1381
- }
1382
-
1383
- if (!useStack) {
1384
- free(msg);
1385
- }
1386
- }
1387
- }
1388
-
1389
- - (NSString *)loggerName
1390
- {
1391
- return @"cocoa.lumberjack.ttyLogger";
1392
- }
1393
-
1394
- @end
1395
-
1396
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1397
-
1398
- @implementation DDTTYLoggerColorProfile
1399
-
1400
- - (instancetype)initWithForegroundColor:(OSColor *)fgColor backgroundColor:(OSColor *)bgColor flag:(int)aMask context:(int)ctxt
1401
- {
1402
- if ((self = [super init]))
1403
- {
1404
- mask = aMask;
1405
- context = ctxt;
1406
-
1407
- CGFloat r, g, b;
1408
-
1409
- if (fgColor)
1410
- {
1411
- [DDTTYLogger getRed:&r green:&g blue:&b fromColor:fgColor];
1412
-
1413
- fg_r = (uint8_t)(r * 255.0f);
1414
- fg_g = (uint8_t)(g * 255.0f);
1415
- fg_b = (uint8_t)(b * 255.0f);
1416
- }
1417
- if (bgColor)
1418
- {
1419
- [DDTTYLogger getRed:&r green:&g blue:&b fromColor:bgColor];
1420
-
1421
- bg_r = (uint8_t)(r * 255.0f);
1422
- bg_g = (uint8_t)(g * 255.0f);
1423
- bg_b = (uint8_t)(b * 255.0f);
1424
- }
1425
-
1426
- if (fgColor && isaColorTTY)
1427
- {
1428
- // Map foreground color to closest available shell color
1429
-
1430
- fgCodeIndex = [DDTTYLogger codeIndexForColor:fgColor];
1431
- fgCodeRaw = [codes_fg objectAtIndex:fgCodeIndex];
1432
-
1433
- NSString *escapeSeq = @"\033[";
1434
-
1435
- NSUInteger len1 = [escapeSeq lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
1436
- NSUInteger len2 = [fgCodeRaw lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
1437
-
1438
- BOOL escapeSeqEnc = [escapeSeq getCString:(fgCode) maxLength:(len1+1) encoding:NSUTF8StringEncoding];
1439
- BOOL fgCodeRawEsc = [fgCodeRaw getCString:(fgCode+len1) maxLength:(len2+1) encoding:NSUTF8StringEncoding];
1440
- if (!escapeSeqEnc || !fgCodeRawEsc) return nil;
1441
-
1442
- fgCodeLen = len1+len2;
1443
- }
1444
- else if (fgColor && isaXcodeColorTTY)
1445
- {
1446
- // Convert foreground color to color code sequence
1447
-
1448
- const char *escapeSeq = XCODE_COLORS_ESCAPE_SEQ;
1449
-
1450
- int result = snprintf(fgCode, 24, "%sfg%u,%u,%u;", escapeSeq, fg_r, fg_g, fg_b);
1451
- fgCodeLen = MIN(result, (24-1));
1452
- }
1453
- else
1454
- {
1455
- // No foreground color or no color support
1456
-
1457
- fgCode[0] = '\0';
1458
- fgCodeLen = 0;
1459
- }
1460
-
1461
- if (bgColor && isaColorTTY)
1462
- {
1463
- // Map background color to closest available shell color
1464
-
1465
- bgCodeIndex = [DDTTYLogger codeIndexForColor:bgColor];
1466
- bgCodeRaw = [codes_bg objectAtIndex:bgCodeIndex];
1467
-
1468
- NSString *escapeSeq = @"\033[";
1469
-
1470
- NSUInteger len1 = [escapeSeq lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
1471
- NSUInteger len2 = [bgCodeRaw lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
1472
-
1473
- BOOL escapeSeqEnc = [escapeSeq getCString:(bgCode) maxLength:(len1+1) encoding:NSUTF8StringEncoding];
1474
- BOOL bgCodeRawEsc = [bgCodeRaw getCString:(bgCode+len1) maxLength:(len2+1) encoding:NSUTF8StringEncoding];
1475
- if (!escapeSeqEnc || !bgCodeRawEsc) return nil;
1476
-
1477
- bgCodeLen = len1+len2;
1478
- }
1479
- else if (bgColor && isaXcodeColorTTY)
1480
- {
1481
- // Convert background color to color code sequence
1482
-
1483
- const char *escapeSeq = XCODE_COLORS_ESCAPE_SEQ;
1484
-
1485
- int result = snprintf(bgCode, 24, "%sbg%u,%u,%u;", escapeSeq, bg_r, bg_g, bg_b);
1486
- bgCodeLen = MIN(result, (24-1));
1487
- }
1488
- else
1489
- {
1490
- // No background color or no color support
1491
-
1492
- bgCode[0] = '\0';
1493
- bgCodeLen = 0;
1494
- }
1495
-
1496
- if (isaColorTTY)
1497
- {
1498
- resetCodeLen = snprintf(resetCode, 8, "\033[0m");
1499
- }
1500
- else if (isaXcodeColorTTY)
1501
- {
1502
- resetCodeLen = snprintf(resetCode, 8, XCODE_COLORS_RESET);
1503
- }
1504
- else
1505
- {
1506
- resetCode[0] = '\0';
1507
- resetCodeLen = 0;
1508
- }
1509
- }
1510
- return self;
1511
- }
1512
-
1513
- - (NSString *)description
1514
- {
1515
- return [NSString stringWithFormat:
1516
- @"<DDTTYLoggerColorProfile: %p mask:%i ctxt:%i fg:%u,%u,%u bg:%u,%u,%u fgCode:%@ bgCode:%@>",
1517
- self, mask, context, fg_r, fg_g, fg_b, bg_r, bg_g, bg_b, fgCodeRaw, bgCodeRaw];
1518
- }
1519
-
1520
- @end