motion-yapper 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -2
- data/.travis.yml +2 -0
- data/Gemfile +1 -0
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/lib/motion-yapper.rb +1 -0
- data/lib/yapper.rb +3 -5
- data/lib/yapper/config.rb +2 -0
- data/lib/yapper/db.rb +105 -40
- data/lib/yapper/document.rb +7 -4
- data/lib/yapper/document/callbacks.rb +0 -7
- data/lib/yapper/document/{persistance.rb → persistence.rb} +27 -21
- data/lib/yapper/document/relation.rb +29 -22
- data/lib/yapper/document/selection.rb +122 -54
- data/lib/yapper/extensions.rb +12 -24
- data/lib/yapper/settings.rb +43 -0
- data/lib/yapper/timestamps.rb +2 -0
- data/lib/yapper/version.rb +1 -1
- data/{yapper.gemspec → motion-yapper.gemspec} +0 -0
- data/spec/integration/{where_spec.rb → criteria_spec.rb} +78 -10
- data/spec/integration/db_spec.rb +70 -0
- data/spec/integration/defaults_spec.rb +37 -0
- data/spec/integration/extensions_spec.rb +14 -0
- data/spec/integration/{persistance_spec.rb → persistence_spec.rb} +0 -0
- data/spec/integration/relation_spec.rb +4 -4
- data/vendor/Podfile.lock +9 -11
- data/vendor/Pods/.build/libPods-CocoaLumberjack.a +0 -0
- data/vendor/Pods/.build/libPods-NSData+MD5Digest.a +0 -0
- data/vendor/Pods/.build/libPods-YapDatabase.a +0 -0
- data/vendor/Pods/.build/libPods.a +0 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDASLLogger.h +4 -4
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDAbstractDatabaseLogger.h +14 -14
- data/vendor/Pods/{CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.h → BuildHeaders/CocoaLumberjack/DDContextFilterLogFormatter.h} +6 -8
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDFileLogger.h +67 -32
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog+LOGV.h +99 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog.h +98 -65
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDMultiFormatter.h +30 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDTTYLogger.h +39 -25
- data/vendor/Pods/BuildHeaders/YapDatabase/NSDictionary+YapDatabase.h +8 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCache.h +1 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCollectionKey.h +3 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabase.h +4 -4
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnection.h +21 -19
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseDefaults.h +1 -1
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionPrivate.h +35 -31
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredView.h +8 -35
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewPrivate.h +0 -2
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTransaction.h +17 -17
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTypes.h +32 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchPrivate.h +8 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabasePrivate.h +43 -21
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationship.h +35 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipConnection.h +29 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdge.h +163 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdgePrivate.h +79 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipNode.h +99 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipOptions.h +59 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipPrivate.h +125 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipTransaction.h +384 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndex.h +49 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +10 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetupPrivate.h +18 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseTransaction.h +131 -21
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseView.h +48 -107
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChange.h +2 -2
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewConnection.h +1 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappings.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewOptions.h +10 -3
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPrivate.h +18 -1
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTransaction.h +75 -24
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTypes.h +99 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h +4 -4
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m +51 -50
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h +14 -14
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m +546 -546
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h +67 -32
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m +1093 -907
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog+LOGV.h +99 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.h +98 -65
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.m +873 -748
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h +39 -25
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m +1284 -1243
- data/vendor/Pods/{BuildHeaders/CocoaLumberjack/ContextFilterLogFormatter.h → CocoaLumberjack/Lumberjack/Extensions/DDContextFilterLogFormatter.h} +6 -8
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/{ContextFilterLogFormatter.m → DDContextFilterLogFormatter.m} +70 -70
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDDispatchQueueLogFormatter.m +253 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.h +30 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.m +127 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt +1 -1
- data/vendor/Pods/CocoaLumberjack/README.markdown +52 -15
- data/vendor/Pods/Headers/CocoaLumberjack/DDASLLogger.h +4 -4
- data/vendor/Pods/Headers/CocoaLumberjack/DDAbstractDatabaseLogger.h +14 -14
- data/vendor/Pods/Headers/CocoaLumberjack/{ContextFilterLogFormatter.h → DDContextFilterLogFormatter.h} +6 -8
- data/vendor/Pods/Headers/CocoaLumberjack/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
- data/vendor/Pods/Headers/CocoaLumberjack/DDFileLogger.h +67 -32
- data/vendor/Pods/Headers/CocoaLumberjack/DDLog+LOGV.h +99 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDLog.h +98 -65
- data/vendor/Pods/Headers/CocoaLumberjack/DDMultiFormatter.h +30 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDTTYLogger.h +39 -25
- data/vendor/Pods/Headers/YapDatabase/YapCollectionKey.h +3 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabase.h +4 -4
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnection.h +21 -19
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredView.h +8 -35
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTransaction.h +17 -17
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTypes.h +32 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationship.h +35 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipConnection.h +29 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipEdge.h +163 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipNode.h +99 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipOptions.h +59 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipTransaction.h +384 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndex.h +49 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseTransaction.h +131 -21
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseView.h +48 -107
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChange.h +2 -2
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewConnection.h +1 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappings.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewOptions.h +10 -3
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTransaction.h +75 -24
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTypes.h +99 -0
- data/vendor/Pods/Headers/____Pods-CocoaLumberjack-prefix.h +2 -0
- data/vendor/Pods/Headers/____Pods-environment.h +15 -15
- data/vendor/Pods/Manifest.lock +9 -11
- data/vendor/Pods/Pods-CocoaLumberjack-Private.xcconfig +1 -1
- data/vendor/Pods/Pods-CocoaLumberjack-prefix.pch +2 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-Private.xcconfig +1 -1
- data/vendor/Pods/Pods-YapDatabase-Private.xcconfig +1 -1
- data/vendor/Pods/{Pods-Acknowledgements.markdown → Pods-acknowledgements.markdown} +0 -37
- data/vendor/Pods/{Pods-Acknowledgements.plist → Pods-acknowledgements.plist} +0 -45
- data/vendor/Pods/Pods-environment.h +15 -15
- data/vendor/Pods/Pods.xcconfig +3 -3
- data/vendor/Pods/Pods.xcodeproj/project.pbxproj +2426 -3155
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-CocoaLumberjack.xcscheme +59 -0
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-NSData+MD5Digest.xcscheme +59 -0
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-YapDatabase.xcscheme +59 -0
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods.xcscheme +59 -0
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/xcschememanagement.plist +31 -0
- data/vendor/Pods/YapDatabase/README.md +3 -1
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/Internal/YapDatabaseFilteredViewPrivate.h +0 -2
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.h +8 -35
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.m +25 -41
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.h +17 -17
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.m +403 -134
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTypes.h +32 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/Internal/YapDatabaseFullTextSearchPrivate.h +8 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.m +8 -8
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.m +113 -62
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/Internal/YapDatabaseExtensionPrivate.h +35 -31
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.m +25 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.m +1 -1
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.m +25 -1
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipEdgePrivate.h +79 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipPrivate.h +125 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.h +35 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.m +129 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.h +29 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.m +802 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.h +163 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.m +408 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipNode.h +99 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.h +59 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.m +29 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.h +384 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.m +5254 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexPrivate.h +10 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexSetupPrivate.h +18 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.h +49 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.m +12 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.m +9 -8
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.m +62 -1
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +148 -45
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPrivate.h +18 -1
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.h +2 -2
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m +15 -9
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.m +211 -64
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.h +48 -107
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.m +10 -7
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.h +1 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.m +13 -22
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.h +10 -3
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.h +75 -24
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.m +725 -244
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTypes.h +99 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.h +8 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.m +19 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.h +1 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.m +12 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.h +1 -1
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.m +3 -3
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabasePrivate.h +43 -21
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.m +4 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.h +3 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.m +5 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.h +4 -4
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.m +84 -93
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.h +21 -19
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.m +381 -209
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.h +131 -21
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.m +587 -267
- data/vendor/Pods/{Pods.bridgesupport → build-iPhoneSimulator/Pods.bridgesupport} +633 -2557
- data/vendor/Pods/build-iPhoneSimulator/libPods.a +0 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.bridgesupport +2 -1
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.h +2 -1
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.m +4 -2
- metadata +80 -108
- data/Gemfile.lock +0 -63
- data/lib/yapper/attachment.rb +0 -48
- data/lib/yapper/document/attachment.rb +0 -26
- data/lib/yapper/sync.rb +0 -134
- data/lib/yapper/sync/data.rb +0 -12
- data/lib/yapper/sync/event.rb +0 -194
- data/lib/yapper/sync/queue.rb +0 -164
- data/spec/integration/all_spec.rb +0 -40
- data/spec/integration/sync_spec.rb +0 -42
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.h +0 -641
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.m +0 -1396
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h +0 -133
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m +0 -327
- data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.h +0 -113
- data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.m +0 -321
- data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.h +0 -71
- data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.m +0 -150
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.m +0 -157
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h +0 -43
- data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.h +0 -68
- data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.m +0 -143
- data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h +0 -370
- data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m +0 -848
- data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.h +0 -89
- data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.m +0 -167
- data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.h +0 -78
- data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.m +0 -191
- data/vendor/Pods/AFNetworking/LICENSE +0 -19
- data/vendor/Pods/AFNetworking/README.md +0 -208
- data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPClient.h +0 -641
- data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h +0 -133
- data/vendor/Pods/BuildHeaders/AFNetworking/AFImageRequestOperation.h +0 -113
- data/vendor/Pods/BuildHeaders/AFNetworking/AFJSONRequestOperation.h +0 -71
- data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
- data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworking.h +0 -43
- data/vendor/Pods/BuildHeaders/AFNetworking/AFPropertyListRequestOperation.h +0 -68
- data/vendor/Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h +0 -370
- data/vendor/Pods/BuildHeaders/AFNetworking/AFXMLRequestOperation.h +0 -89
- data/vendor/Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h +0 -78
- data/vendor/Pods/BuildHeaders/Reachability/Reachability.h +0 -109
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.m +0 -251
- data/vendor/Pods/Headers/AFNetworking/AFHTTPClient.h +0 -641
- data/vendor/Pods/Headers/AFNetworking/AFHTTPRequestOperation.h +0 -133
- data/vendor/Pods/Headers/AFNetworking/AFImageRequestOperation.h +0 -113
- data/vendor/Pods/Headers/AFNetworking/AFJSONRequestOperation.h +0 -71
- data/vendor/Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
- data/vendor/Pods/Headers/AFNetworking/AFNetworking.h +0 -43
- data/vendor/Pods/Headers/AFNetworking/AFPropertyListRequestOperation.h +0 -68
- data/vendor/Pods/Headers/AFNetworking/AFURLConnectionOperation.h +0 -370
- data/vendor/Pods/Headers/AFNetworking/AFXMLRequestOperation.h +0 -89
- data/vendor/Pods/Headers/AFNetworking/UIImageView+AFNetworking.h +0 -78
- data/vendor/Pods/Headers/Reachability/Reachability.h +0 -109
- data/vendor/Pods/Headers/YapDatabase/YapCache.h +0 -90
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnectionState.h +0 -29
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseDefaults.h +0 -37
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionPrivate.h +0 -440
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewPrivate.h +0 -19
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchPrivate.h +0 -69
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseLogging.h +0 -158
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseManager.h +0 -17
- data/vendor/Pods/Headers/YapDatabase/YapDatabasePrivate.h +0 -424
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +0 -73
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseStatement.h +0 -13
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseString.h +0 -121
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChangePrivate.h +0 -94
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappingsPrivate.h +0 -72
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPage.h +0 -36
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPageMetadata.h +0 -27
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPrivate.h +0 -153
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +0 -17
- data/vendor/Pods/Headers/YapDatabase/YapMemoryTable.h +0 -74
- data/vendor/Pods/Headers/YapDatabase/YapNull.h +0 -17
- data/vendor/Pods/Headers/YapDatabase/YapTouch.h +0 -15
- data/vendor/Pods/Headers/____Pods-AFNetworking-prefix.h +0 -17
- data/vendor/Pods/Headers/____Pods-Reachability-prefix.h +0 -5
- data/vendor/Pods/Pods-AFNetworking-Private.xcconfig +0 -5
- data/vendor/Pods/Pods-AFNetworking-dummy.m +0 -5
- data/vendor/Pods/Pods-AFNetworking-prefix.pch +0 -17
- data/vendor/Pods/Pods-AFNetworking.xcconfig +0 -1
- data/vendor/Pods/Pods-Reachability-Private.xcconfig +0 -5
- data/vendor/Pods/Pods-Reachability-dummy.m +0 -5
- data/vendor/Pods/Pods-Reachability-prefix.pch +0 -5
- data/vendor/Pods/Pods-Reachability.xcconfig +0 -1
- data/vendor/Pods/Reachability/LICENCE.txt +0 -24
- data/vendor/Pods/Reachability/README.md +0 -65
- data/vendor/Pods/Reachability/Reachability.h +0 -109
- data/vendor/Pods/Reachability/Reachability.m +0 -527
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
#import <Foundation/Foundation.h>
|
|
2
2
|
#if TARGET_OS_IPHONE
|
|
3
|
-
#import <UIKit/UIColor.h>
|
|
3
|
+
#import <UIKit/UIColor.h> // iOS
|
|
4
|
+
#elif !defined (COCOAPODS_POD_AVAILABLE_CocoaLumberjack_CLI)
|
|
5
|
+
#import <AppKit/NSColor.h> // OS X with AppKit
|
|
4
6
|
#else
|
|
5
|
-
#import
|
|
7
|
+
#import "CLIColor.h" // OS X without AppKit
|
|
6
8
|
#endif
|
|
7
9
|
|
|
8
10
|
#import "DDLog.h"
|
|
9
11
|
|
|
12
|
+
#define LOG_CONTEXT_ALL INT_MAX
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* Welcome to Cocoa Lumberjack!
|
|
12
16
|
*
|
|
13
17
|
* The project page has a wealth of documentation if you have any questions.
|
|
14
|
-
* https://github.com/
|
|
18
|
+
* https://github.com/CocoaLumberjack/CocoaLumberjack
|
|
15
19
|
*
|
|
16
20
|
* If you're new to the project you may wish to read the "Getting Started" wiki.
|
|
17
|
-
* https://github.com/
|
|
21
|
+
* https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
|
|
18
22
|
*
|
|
19
23
|
*
|
|
20
24
|
* This class provides a logger for Terminal output or Xcode console output,
|
|
@@ -33,23 +37,23 @@
|
|
|
33
37
|
|
|
34
38
|
@interface DDTTYLogger : DDAbstractLogger <DDLogger>
|
|
35
39
|
{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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;
|
|
50
54
|
}
|
|
51
55
|
|
|
52
|
-
+ (
|
|
56
|
+
+ (instancetype)sharedInstance;
|
|
53
57
|
|
|
54
58
|
/* Inherited from the DDLogger protocol:
|
|
55
59
|
*
|
|
@@ -59,7 +63,7 @@
|
|
|
59
63
|
* or it may use its own built in formatting style.
|
|
60
64
|
*
|
|
61
65
|
* More information about formatters can be found here:
|
|
62
|
-
* https://github.com/
|
|
66
|
+
* https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/CustomFormatters
|
|
63
67
|
*
|
|
64
68
|
* The actual implementation of these methods is inherited from DDAbstractLogger.
|
|
65
69
|
|
|
@@ -103,12 +107,14 @@
|
|
|
103
107
|
* If you run the application from a shell, then DDTTYLogger will automatically map the given color to
|
|
104
108
|
* the closest available color. (xterm-256color or xterm-color which have 256 and 16 supported colors respectively.)
|
|
105
109
|
*
|
|
106
|
-
* This method invokes setForegroundColor:backgroundColor:forFlag:context: and
|
|
110
|
+
* This method invokes setForegroundColor:backgroundColor:forFlag:context: and applies it to `LOG_CONTEXT_ALL`.
|
|
107
111
|
**/
|
|
108
112
|
#if TARGET_OS_IPHONE
|
|
109
113
|
- (void)setForegroundColor:(UIColor *)txtColor backgroundColor:(UIColor *)bgColor forFlag:(int)mask;
|
|
110
|
-
#
|
|
114
|
+
#elif !defined (COCOAPODS_POD_AVAILABLE_CocoaLumberjack_CLI)
|
|
111
115
|
- (void)setForegroundColor:(NSColor *)txtColor backgroundColor:(NSColor *)bgColor forFlag:(int)mask;
|
|
116
|
+
#else
|
|
117
|
+
- (void)setForegroundColor:(CLIColor *)txtColor backgroundColor:(CLIColor *)bgColor forFlag:(int)mask;
|
|
112
118
|
#endif
|
|
113
119
|
|
|
114
120
|
/**
|
|
@@ -117,13 +123,17 @@
|
|
|
117
123
|
* A logging context is often used to identify log messages coming from a 3rd party framework,
|
|
118
124
|
* although logging context's can be used for many different functions.
|
|
119
125
|
*
|
|
126
|
+
* Use LOG_CONTEXT_ALL to set the deafult color for all contexts that have no specific color set defined.
|
|
127
|
+
*
|
|
120
128
|
* Logging context's are explained in further detail here:
|
|
121
|
-
* https://github.com/
|
|
129
|
+
* https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/CustomContext
|
|
122
130
|
**/
|
|
123
131
|
#if TARGET_OS_IPHONE
|
|
124
132
|
- (void)setForegroundColor:(UIColor *)txtColor backgroundColor:(UIColor *)bgColor forFlag:(int)mask context:(int)ctxt;
|
|
125
|
-
#
|
|
133
|
+
#elif !defined (COCOAPODS_POD_AVAILABLE_CocoaLumberjack_CLI)
|
|
126
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;
|
|
127
137
|
#endif
|
|
128
138
|
|
|
129
139
|
/**
|
|
@@ -140,6 +150,8 @@
|
|
|
140
150
|
* UIColor *purple = [UIColor colorWithRed:(64/255.0) green:(0/255.0) blue:(128/255.0) alpha:1.0];
|
|
141
151
|
* #else
|
|
142
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
|
|
143
155
|
*
|
|
144
156
|
* [[DDTTYLogger sharedInstance] setForegroundColor:purple backgroundColor:nil forTag:PurpleTag];
|
|
145
157
|
* [DDLog addLogger:[DDTTYLogger sharedInstance]];
|
|
@@ -150,8 +162,10 @@
|
|
|
150
162
|
**/
|
|
151
163
|
#if TARGET_OS_IPHONE
|
|
152
164
|
- (void)setForegroundColor:(UIColor *)txtColor backgroundColor:(UIColor *)bgColor forTag:(id <NSCopying>)tag;
|
|
153
|
-
#
|
|
165
|
+
#elif !defined (COCOAPODS_POD_AVAILABLE_CocoaLumberjack_CLI)
|
|
154
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;
|
|
155
169
|
#endif
|
|
156
170
|
|
|
157
171
|
/**
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
* Welcome to Cocoa Lumberjack!
|
|
8
8
|
*
|
|
9
9
|
* The project page has a wealth of documentation if you have any questions.
|
|
10
|
-
* https://github.com/
|
|
10
|
+
* https://github.com/CocoaLumberjack/CocoaLumberjack
|
|
11
11
|
*
|
|
12
12
|
* If you're new to the project you may wish to read the "Getting Started" wiki.
|
|
13
|
-
* https://github.com/
|
|
13
|
+
* https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
|
|
14
14
|
**/
|
|
15
15
|
|
|
16
16
|
#if ! __has_feature(objc_arc)
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
#define NSLogError(frmt, ...) do{ if(LOG_LEVEL >= 1) NSLog((frmt), ##__VA_ARGS__); } while(0)
|
|
30
30
|
#define NSLogWarn(frmt, ...) do{ if(LOG_LEVEL >= 2) NSLog((frmt), ##__VA_ARGS__); } while(0)
|
|
31
31
|
#define NSLogInfo(frmt, ...) do{ if(LOG_LEVEL >= 3) NSLog((frmt), ##__VA_ARGS__); } while(0)
|
|
32
|
-
#define
|
|
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)
|
|
33
34
|
|
|
34
35
|
// Xcode does NOT natively support colors in the Xcode debugging console.
|
|
35
36
|
// You'll need to install the XcodeColors plugin to see colors in the Xcode console.
|
|
@@ -64,15 +65,14 @@
|
|
|
64
65
|
// Some simple defines to make life easier on ourself
|
|
65
66
|
|
|
66
67
|
#if TARGET_OS_IPHONE
|
|
68
|
+
#define OSColor UIColor
|
|
67
69
|
#define MakeColor(r, g, b) [UIColor colorWithRed:(r/255.0f) green:(g/255.0f) blue:(b/255.0f) alpha:1.0f]
|
|
68
|
-
#
|
|
70
|
+
#elif !defined (COCOAPODS_POD_AVAILABLE_CocoaLumberjack_CLI)
|
|
71
|
+
#define OSColor NSColor
|
|
69
72
|
#define MakeColor(r, g, b) [NSColor colorWithCalibratedRed:(r/255.0f) green:(g/255.0f) blue:(b/255.0f) alpha:1.0f]
|
|
70
|
-
#endif
|
|
71
|
-
|
|
72
|
-
#if TARGET_OS_IPHONE
|
|
73
|
-
#define OSColor UIColor
|
|
74
73
|
#else
|
|
75
|
-
#define OSColor
|
|
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
76
|
#endif
|
|
77
77
|
|
|
78
78
|
// If running in a shell, not all RGB colors will be supported.
|
|
@@ -88,34 +88,34 @@
|
|
|
88
88
|
|
|
89
89
|
@interface DDTTYLoggerColorProfile : NSObject {
|
|
90
90
|
@public
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
116
|
}
|
|
117
117
|
|
|
118
|
-
- (
|
|
118
|
+
- (instancetype)initWithForegroundColor:(OSColor *)fgColor backgroundColor:(OSColor *)bgColor flag:(int)mask context:(int)ctxt;
|
|
119
119
|
|
|
120
120
|
@end
|
|
121
121
|
|
|
@@ -143,105 +143,105 @@ static DDTTYLogger *sharedInstance;
|
|
|
143
143
|
**/
|
|
144
144
|
+ (void)initialize_colors_16
|
|
145
145
|
{
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
191
|
#if MAP_TO_TERMINAL_APP_COLORS
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
214
|
#else
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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
237
|
#endif
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
245
|
}
|
|
246
246
|
|
|
247
247
|
/**
|
|
@@ -252,459 +252,470 @@ static DDTTYLogger *sharedInstance;
|
|
|
252
252
|
**/
|
|
253
253
|
+ (void)initialize_colors_256
|
|
254
254
|
{
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
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
668
|
}
|
|
669
669
|
|
|
670
670
|
+ (void)getRed:(CGFloat *)rPtr green:(CGFloat *)gPtr blue:(CGFloat *)bPtr fromColor:(OSColor *)color
|
|
671
671
|
{
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
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
|
|
708
719
|
}
|
|
709
720
|
|
|
710
721
|
/**
|
|
@@ -717,41 +728,41 @@ static DDTTYLogger *sharedInstance;
|
|
|
717
728
|
**/
|
|
718
729
|
+ (NSUInteger)codeIndexForColor:(OSColor *)inColor
|
|
719
730
|
{
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
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;
|
|
755
766
|
}
|
|
756
767
|
|
|
757
768
|
/**
|
|
@@ -764,592 +775,620 @@ static DDTTYLogger *sharedInstance;
|
|
|
764
775
|
**/
|
|
765
776
|
+ (void)initialize
|
|
766
777
|
{
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
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
|
+
}
|
|
806
817
|
}
|
|
807
818
|
|
|
808
|
-
+ (
|
|
819
|
+
+ (instancetype)sharedInstance
|
|
809
820
|
{
|
|
810
|
-
|
|
821
|
+
return sharedInstance;
|
|
811
822
|
}
|
|
812
823
|
|
|
813
824
|
- (id)init
|
|
814
825
|
{
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
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;
|
|
857
876
|
}
|
|
858
877
|
|
|
859
878
|
- (void)loadDefaultColorProfiles
|
|
860
879
|
{
|
|
861
|
-
|
|
862
|
-
|
|
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];
|
|
863
882
|
}
|
|
864
883
|
|
|
865
884
|
- (BOOL)colorsEnabled
|
|
866
885
|
{
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
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;
|
|
891
910
|
}
|
|
892
911
|
|
|
893
912
|
- (void)setColorsEnabled:(BOOL)newColorsEnabled
|
|
894
913
|
{
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
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
|
+
});
|
|
922
941
|
}
|
|
923
942
|
|
|
924
943
|
- (void)setForegroundColor:(OSColor *)txtColor backgroundColor:(OSColor *)bgColor forFlag:(int)mask
|
|
925
944
|
{
|
|
926
|
-
|
|
945
|
+
[self setForegroundColor:txtColor backgroundColor:bgColor forFlag:mask context:LOG_CONTEXT_ALL];
|
|
927
946
|
}
|
|
928
947
|
|
|
929
948
|
- (void)setForegroundColor:(OSColor *)txtColor backgroundColor:(OSColor *)bgColor forFlag:(int)mask context:(int)ctxt
|
|
930
949
|
{
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
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
|
+
}
|
|
974
993
|
}
|
|
975
994
|
|
|
976
995
|
- (void)setForegroundColor:(OSColor *)txtColor backgroundColor:(OSColor *)bgColor forTag:(id <NSCopying>)tag
|
|
977
996
|
{
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
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
|
+
}
|
|
1009
1028
|
}
|
|
1010
1029
|
|
|
1011
1030
|
- (void)clearColorsForFlag:(int)mask
|
|
1012
1031
|
{
|
|
1013
|
-
|
|
1032
|
+
[self clearColorsForFlag:mask context:0];
|
|
1014
1033
|
}
|
|
1015
1034
|
|
|
1016
1035
|
- (void)clearColorsForFlag:(int)mask context:(int)context
|
|
1017
1036
|
{
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
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
|
+
}
|
|
1053
1072
|
}
|
|
1054
1073
|
|
|
1055
1074
|
- (void)clearColorsForTag:(id <NSCopying>)tag
|
|
1056
1075
|
{
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
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
|
+
}
|
|
1080
1099
|
}
|
|
1081
1100
|
|
|
1082
1101
|
- (void)clearColorsForAllFlags
|
|
1083
1102
|
{
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
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
|
+
}
|
|
1105
1124
|
}
|
|
1106
1125
|
|
|
1107
1126
|
- (void)clearColorsForAllTags
|
|
1108
1127
|
{
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
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
|
+
}
|
|
1130
1149
|
}
|
|
1131
1150
|
|
|
1132
1151
|
- (void)clearAllColors
|
|
1133
1152
|
{
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
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
|
+
}
|
|
1156
1175
|
}
|
|
1157
1176
|
|
|
1158
1177
|
- (void)logMessage:(DDLogMessage *)logMessage
|
|
1159
1178
|
{
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
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;
|
|
1219
1258
|
|
|
1220
|
-
|
|
1221
|
-
|
|
1259
|
+
v[1].iov_base = colorProfile->bgCode;
|
|
1260
|
+
v[1].iov_len = colorProfile->bgCodeLen;
|
|
1222
1261
|
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
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;
|
|
1292
1331
|
|
|
1293
|
-
|
|
1294
|
-
|
|
1332
|
+
v[1].iov_base = colorProfile->bgCode;
|
|
1333
|
+
v[1].iov_len = colorProfile->bgCodeLen;
|
|
1295
1334
|
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
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;
|
|
1303
1342
|
|
|
1304
|
-
|
|
1305
|
-
|
|
1343
|
+
v[1].iov_base = "";
|
|
1344
|
+
v[1].iov_len = 0;
|
|
1306
1345
|
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
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
|
+
}
|
|
1348
1387
|
}
|
|
1349
1388
|
|
|
1350
1389
|
- (NSString *)loggerName
|
|
1351
1390
|
{
|
|
1352
|
-
|
|
1391
|
+
return @"cocoa.lumberjack.ttyLogger";
|
|
1353
1392
|
}
|
|
1354
1393
|
|
|
1355
1394
|
@end
|
|
@@ -1358,122 +1397,124 @@ static DDTTYLogger *sharedInstance;
|
|
|
1358
1397
|
|
|
1359
1398
|
@implementation DDTTYLoggerColorProfile
|
|
1360
1399
|
|
|
1361
|
-
- (
|
|
1400
|
+
- (instancetype)initWithForegroundColor:(OSColor *)fgColor backgroundColor:(OSColor *)bgColor flag:(int)aMask context:(int)ctxt
|
|
1362
1401
|
{
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
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;
|
|
1470
1511
|
}
|
|
1471
1512
|
|
|
1472
1513
|
- (NSString *)description
|
|
1473
1514
|
{
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
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];
|
|
1477
1518
|
}
|
|
1478
1519
|
|
|
1479
1520
|
@end
|