From f19460d1ef5901d3a2f8ef0a9d044c5226b2c6d9 Mon Sep 17 00:00:00 2001 From: Jebeom Gyeong Date: Sat, 22 Feb 2020 20:13:32 -0800 Subject: [PATCH 1/5] Removed out-dated test framework(GHUnit). Applied XCTest. --- AppledocTests_prefix.pch | 27 - Application/GBAppledocApplication.h | 2 + Application/GBAppledocApplication.m | 72 +- Application/GBApplicationSettingsProvider.m | 4 +- Common/GBLog.h | 7 + Common/GBLog.m | 28 +- Common/GBTask.m | 2 +- .../ThirdParty/CocoaLumberjack/DDASLLogger.m | 86 - .../ThirdParty/CocoaLumberjack/DDFileLogger.h | 275 -- .../ThirdParty/CocoaLumberjack/DDFileLogger.m | 1469 ------ Common/ThirdParty/CocoaLumberjack/DDLog.h | 529 -- Common/ThirdParty/CocoaLumberjack/DDLog.m | 1440 ------ .../ThirdParty/CocoaLumberjack/DDTTYLogger.h | 49 - .../ThirdParty/CocoaLumberjack/DDTTYLogger.m | 173 - Common/ThirdParty/DDCli/DDCliApplication.m | 36 +- Common/ThirdParty/DDCli/DDCliParseException.m | 6 +- Common/ThirdParty/DDCli/DDCliUtil.m | 4 +- Common/ThirdParty/DDCli/DDGetoptLongParser.m | 23 +- .../ThirdParty/DDMinizip/minizip}/LICENSE | 0 .../ThirdParty/DDMinizip/minizip}/crypt.c | 0 .../ThirdParty/DDMinizip/minizip}/crypt.h | 0 .../ThirdParty/DDMinizip/minizip}/ioapi.c | 0 .../ThirdParty/DDMinizip/minizip}/ioapi.h | 0 .../ThirdParty/DDMinizip/minizip}/ioapi_buf.c | 10 +- .../ThirdParty/DDMinizip/minizip}/ioapi_buf.h | 0 .../ThirdParty/DDMinizip/minizip}/ioapi_mem.c | 0 .../ThirdParty/DDMinizip/minizip}/ioapi_mem.h | 0 .../DDMinizip/minizip}/minishared.c | 0 .../DDMinizip/minizip}/minishared.h | 0 .../ThirdParty/DDMinizip/minizip}/unzip.c | 0 .../ThirdParty/DDMinizip/minizip}/unzip.h | 0 .../ThirdParty/DDMinizip/minizip}/zip.c | 0 .../ThirdParty/DDMinizip/minizip}/zip.h | 0 .../ThirdParty}/DDMinizip/src/DDZipReader.h | 0 .../ThirdParty}/DDMinizip/src/DDZipReader.m | 0 .../ThirdParty}/DDMinizip/src/DDZipWriter.h | 0 .../ThirdParty}/DDMinizip/src/DDZipWriter.m | 0 .../DDMinizip/src/DDZippedFileInfo.h | 0 .../DDMinizip/src/DDZippedFileInfo.m | 0 .../ThirdParty/DDUtils/DDXcodeProjectFile.m | 49 +- Common/ThirdParty/Miscellaneous/timing.h | 2 + Generating/GBDocSetFinalizeGenerator.m | 8 +- Generating/GBDocSetInstallGenerator.m | 7 +- Generating/GBDocSetOutputGenerator.m | 45 +- Generating/GBDocSetPublishGenerator.m | 19 +- Generating/GBGenerator.m | 18 +- Generating/GBHTMLOutputGenerator.m | 53 +- Generating/GBHTMLTemplateVariablesProvider.h | 5 + Generating/GBHTMLTemplateVariablesProvider.m | 2 +- Generating/GBMarkdownOutputGenerator.m | 33 +- Generating/GBOutputGenerator.m | 25 +- Generating/GBTemplateFilesHandler.m | 30 +- Generating/GBTemplateHandler.m | 28 +- Model/GBAdoptedProtocolsProvider.m | 7 +- Model/GBCategoryData.m | 4 +- Model/GBClassData.m | 6 +- Model/GBComment.h | 2 +- Model/GBComment.m | 1 + Model/GBCommentComponentsList.m | 2 +- Model/GBDocumentData.m | 3 +- Model/GBEnumConstantProvider.m | 2 +- Model/GBIvarData.m | 2 +- Model/GBIvarsProvider.m | 6 +- Model/GBMethodData.m | 7 +- Model/GBMethodsProvider.m | 10 +- Model/GBModelBase.m | 2 +- Model/GBProtocolData.m | 4 +- Model/GBStore.m | 20 +- Parsing/GBObjectiveCParser.m | 49 +- Parsing/GBParser.m | 40 +- Parsing/GBTokenizer.h | 4 +- Parsing/GBTokenizer.m | 5 +- Podfile | 12 +- Podfile.lock | 43 +- Pods/CocoaLumberjack/LICENSE.txt | 18 + .../Lumberjack/DDASLLogCapture.h | 23 + .../Lumberjack/DDASLLogCapture.m | 180 + .../CocoaLumberjack/Lumberjack}/DDASLLogger.h | 14 +- Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m | 95 + .../Lumberjack/DDAbstractDatabaseLogger.h | 102 + .../Lumberjack/DDAbstractDatabaseLogger.m | 727 +++ .../CocoaLumberjack/Lumberjack/DDFileLogger.h | 387 ++ .../CocoaLumberjack/Lumberjack/DDFileLogger.m | 1559 ++++++ Pods/CocoaLumberjack/Lumberjack/DDLog+LOGV.h | 99 + Pods/CocoaLumberjack/Lumberjack/DDLog.h | 692 +++ Pods/CocoaLumberjack/Lumberjack/DDLog.m | 1254 +++++ Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h | 181 + Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m | 1508 ++++++ .../Extensions/DDContextFilterLogFormatter.h | 63 + .../Extensions/DDContextFilterLogFormatter.m | 191 + .../Extensions/DDDispatchQueueLogFormatter.h | 128 + .../Extensions/DDDispatchQueueLogFormatter.m | 253 + .../Lumberjack/Extensions/DDMultiFormatter.h | 30 + .../Lumberjack/Extensions/DDMultiFormatter.m | 132 + .../Lumberjack/Extensions/README.txt | 7 + Pods/CocoaLumberjack/README.markdown | 73 + Pods/DDMinizip/LICENSE.rtf | 41 - Pods/DDMinizip/README.md | 51 - Pods/GHUnit/Classes-MacOSX/UI/GHTestApp.h | 23 - Pods/GHUnit/Classes-MacOSX/UI/GHTestApp.m | 54 - Pods/GHUnit/Classes-MacOSX/UI/GHTestApp.xib | 143 - .../UI/GHTestOutlineViewModel.h | 32 - .../UI/GHTestOutlineViewModel.m | 155 - Pods/GHUnit/Classes-MacOSX/UI/GHTestView.xib | 1957 -------- .../Classes-MacOSX/UI/GHTestViewController.h | 106 - .../Classes-MacOSX/UI/GHTestViewController.m | 430 -- .../GHUnit/Classes-MacOSX/UI/GHTestWindow.xib | 1538 ------ .../UI/GHTestWindowController.h | 41 - .../UI/GHTestWindowController.m | 70 - Pods/GHUnit/Classes/GHAsyncTestCase.h | 163 - Pods/GHUnit/Classes/GHAsyncTestCase.m | 179 - Pods/GHUnit/Classes/GHTest/GHTest+JUnitXML.h | 44 - Pods/GHUnit/Classes/GHTest/GHTest+JUnitXML.m | 48 - Pods/GHUnit/Classes/GHTest/GHTest.h | 272 - Pods/GHUnit/Classes/GHTest/GHTest.m | 268 - .../Classes/GHTest/GHTestGroup+JUnitXML.h | 42 - .../Classes/GHTest/GHTestGroup+JUnitXML.m | 64 - Pods/GHUnit/Classes/GHTest/GHTestGroup.h | 186 - Pods/GHUnit/Classes/GHTest/GHTestGroup.m | 388 -- Pods/GHUnit/Classes/GHTest/GHTestOperation.h | 47 - Pods/GHUnit/Classes/GHTest/GHTestOperation.m | 58 - Pods/GHUnit/Classes/GHTest/GHTestRunner.h | 221 - Pods/GHUnit/Classes/GHTest/GHTestRunner.m | 311 -- Pods/GHUnit/Classes/GHTest/GHTestSuite.h | 118 - Pods/GHUnit/Classes/GHTest/GHTestSuite.m | 167 - Pods/GHUnit/Classes/GHTest/GHTesting.h | 153 - Pods/GHUnit/Classes/GHTest/GHTesting.m | 417 -- .../NSException+GHTestFailureExceptions.h | 97 - .../NSException+GHTestFailureExceptions.m | 278 -- .../Classes/GHTest/NSValue+GHValueFormatter.h | 71 - .../Classes/GHTest/NSValue+GHValueFormatter.m | 161 - Pods/GHUnit/Classes/GHTestCase.h | 161 - Pods/GHUnit/Classes/GHTestCase.m | 67 - Pods/GHUnit/Classes/GHTestMacros.h | 1049 ---- Pods/GHUnit/Classes/GHTestUtils.h | 51 - Pods/GHUnit/Classes/GHTestUtils.m | 58 - Pods/GHUnit/Classes/GHUnit.h | 56 - .../Classes/Mock/GHMockNSHTTPURLResponse.h | 46 - .../Classes/Mock/GHMockNSHTTPURLResponse.m | 62 - .../Classes/Mock/GHMockNSURLConnection.h | 167 - .../Classes/Mock/GHMockNSURLConnection.m | 146 - .../GHUnit/Classes/SharedUI/GHTestViewModel.h | 218 - .../GHUnit/Classes/SharedUI/GHTestViewModel.m | 406 -- Pods/GHUnit/LICENSE | 25 - .../GTM/Foundation/GTMNSString+XML.h | 51 - .../GTM/Foundation/GTMNSString+XML.m | 181 - .../GTM/Foundation/GTMObjC2Runtime.h | 113 - .../GTM/Foundation/GTMObjC2Runtime.m | 163 - Pods/GHUnit/Libraries/GTM/GTMDefines.h | 253 - Pods/GHUnit/README.md | 81 - .../Private/CocoaLumberjack/DDASLLogCapture.h | 1 + .../Private/CocoaLumberjack/DDASLLogger.h | 1 + .../DDAbstractDatabaseLogger.h | 1 + .../DDContextFilterLogFormatter.h | 1 + .../DDDispatchQueueLogFormatter.h | 1 + .../Private/CocoaLumberjack/DDFileLogger.h | 1 + .../Private/CocoaLumberjack/DDLog+LOGV.h | 1 + Pods/Headers/Private/CocoaLumberjack/DDLog.h | 1 + .../CocoaLumberjack/DDMultiFormatter.h | 1 + .../Private/CocoaLumberjack/DDTTYLogger.h | 1 + Pods/Headers/Private/DDMinizip/DDZipReader.h | 1 - Pods/Headers/Private/DDMinizip/DDZipWriter.h | 1 - .../Private/DDMinizip/DDZippedFileInfo.h | 1 - Pods/Headers/Private/GHUnit/GHAsyncTestCase.h | 1 - .../Private/GHUnit/GHMockNSHTTPURLResponse.h | 1 - .../Private/GHUnit/GHMockNSURLConnection.h | 1 - Pods/Headers/Private/GHUnit/GHTest+JUnitXML.h | 1 - Pods/Headers/Private/GHUnit/GHTest.h | 1 - Pods/Headers/Private/GHUnit/GHTestApp.h | 1 - Pods/Headers/Private/GHUnit/GHTestCase.h | 1 - .../Private/GHUnit/GHTestGroup+JUnitXML.h | 1 - Pods/Headers/Private/GHUnit/GHTestGroup.h | 1 - Pods/Headers/Private/GHUnit/GHTestMacros.h | 1 - Pods/Headers/Private/GHUnit/GHTestOperation.h | 1 - .../Private/GHUnit/GHTestOutlineViewModel.h | 1 - Pods/Headers/Private/GHUnit/GHTestRunner.h | 1 - Pods/Headers/Private/GHUnit/GHTestSuite.h | 1 - Pods/Headers/Private/GHUnit/GHTestUtils.h | 1 - .../Private/GHUnit/GHTestViewController.h | 1 - Pods/Headers/Private/GHUnit/GHTestViewModel.h | 1 - .../Private/GHUnit/GHTestWindowController.h | 1 - Pods/Headers/Private/GHUnit/GHTesting.h | 1 - Pods/Headers/Private/GHUnit/GHUnit.h | 1 - Pods/Headers/Private/GHUnit/GTMDefines.h | 1 - Pods/Headers/Private/GHUnit/GTMNSString+XML.h | 1 - Pods/Headers/Private/GHUnit/GTMObjC2Runtime.h | 1 - .../NSException+GHTestFailureExceptions.h | 1 - .../Private/GHUnit/NSValue+GHValueFormatter.h | 1 - Pods/Headers/Private/Minizip/crypt.h | 1 - Pods/Headers/Private/Minizip/ioapi.h | 1 - Pods/Headers/Private/Minizip/ioapi_buf.h | 1 - Pods/Headers/Private/Minizip/ioapi_mem.h | 1 - Pods/Headers/Private/Minizip/minishared.h | 1 - Pods/Headers/Private/Minizip/unzip.h | 1 - Pods/Headers/Private/Minizip/zip.h | 1 - .../Public/CocoaLumberjack/DDASLLogCapture.h | 1 + .../Public/CocoaLumberjack/DDASLLogger.h | 1 + .../DDAbstractDatabaseLogger.h | 1 + .../DDContextFilterLogFormatter.h | 1 + .../DDDispatchQueueLogFormatter.h | 1 + .../Public/CocoaLumberjack/DDFileLogger.h | 1 + .../Public/CocoaLumberjack/DDLog+LOGV.h | 1 + Pods/Headers/Public/CocoaLumberjack/DDLog.h | 1 + .../Public/CocoaLumberjack/DDMultiFormatter.h | 1 + .../Public/CocoaLumberjack/DDTTYLogger.h | 1 + Pods/Headers/Public/DDMinizip/DDZipReader.h | 1 - Pods/Headers/Public/DDMinizip/DDZipWriter.h | 1 - .../Public/DDMinizip/DDZippedFileInfo.h | 1 - Pods/Headers/Public/GHUnit/GHAsyncTestCase.h | 1 - .../Public/GHUnit/GHMockNSHTTPURLResponse.h | 1 - .../Public/GHUnit/GHMockNSURLConnection.h | 1 - Pods/Headers/Public/GHUnit/GHTest+JUnitXML.h | 1 - Pods/Headers/Public/GHUnit/GHTest.h | 1 - Pods/Headers/Public/GHUnit/GHTestApp.h | 1 - Pods/Headers/Public/GHUnit/GHTestCase.h | 1 - .../Public/GHUnit/GHTestGroup+JUnitXML.h | 1 - Pods/Headers/Public/GHUnit/GHTestGroup.h | 1 - Pods/Headers/Public/GHUnit/GHTestMacros.h | 1 - Pods/Headers/Public/GHUnit/GHTestOperation.h | 1 - .../Public/GHUnit/GHTestOutlineViewModel.h | 1 - Pods/Headers/Public/GHUnit/GHTestRunner.h | 1 - Pods/Headers/Public/GHUnit/GHTestSuite.h | 1 - Pods/Headers/Public/GHUnit/GHTestUtils.h | 1 - .../Public/GHUnit/GHTestViewController.h | 1 - Pods/Headers/Public/GHUnit/GHTestViewModel.h | 1 - .../Public/GHUnit/GHTestWindowController.h | 1 - Pods/Headers/Public/GHUnit/GHTesting.h | 1 - Pods/Headers/Public/GHUnit/GHUnit.h | 1 - Pods/Headers/Public/GHUnit/GTMDefines.h | 1 - Pods/Headers/Public/GHUnit/GTMNSString+XML.h | 1 - Pods/Headers/Public/GHUnit/GTMObjC2Runtime.h | 1 - .../NSException+GHTestFailureExceptions.h | 1 - .../Public/GHUnit/NSValue+GHValueFormatter.h | 1 - Pods/Headers/Public/Minizip/crypt.h | 1 - Pods/Headers/Public/Minizip/ioapi.h | 1 - Pods/Headers/Public/Minizip/ioapi_buf.h | 1 - Pods/Headers/Public/Minizip/ioapi_mem.h | 1 - Pods/Headers/Public/Minizip/minishared.h | 1 - Pods/Headers/Public/Minizip/unzip.h | 1 - Pods/Headers/Public/Minizip/zip.h | 1 - Pods/Local Podspecs/DDMinizip.podspec.json | 19 - Pods/Local Podspecs/Minizip.podspec.json | 46 - Pods/Manifest.lock | 43 +- Pods/Minizip/README.md | 84 - .../Source/OCMock/NSInvocation+OCMAdditions.m | 17 +- Pods/OCMock/Source/OCMock/OCClassMockObject.m | 22 +- Pods/OCMock/Source/OCMock/OCMFunctions.m | 111 +- .../Source/OCMock/OCMFunctionsPrivate.h | 1 - Pods/OCMock/Source/OCMock/OCMockObject.m | 16 +- Pods/Pods.xcodeproj/project.pbxproj | 4360 ++++++++--------- .../CocoaLumberjack/CocoaLumberjack-dummy.m | 5 + .../CocoaLumberjack-prefix.pch} | 0 .../CocoaLumberjack/CocoaLumberjack.xcconfig | 10 + .../DDMinizip/DDMinizip-dummy.m | 5 - .../DDMinizip/DDMinizip.xcconfig | 9 - .../Discount/Discount.xcconfig | 9 +- .../GHUnit/GHUnit-dummy.m | 5 - .../GHUnit/GHUnit-prefix.pch | 12 - .../GHUnit/GHUnit.xcconfig | 9 - .../GRMustache/GRMustache.xcconfig | 11 +- .../JRSwizzle/JRSwizzle.xcconfig | 10 +- .../Minizip/Minizip-dummy.m | 5 - .../Minizip/Minizip-prefix.pch | 12 - .../Minizip/Minizip.xcconfig | 10 - .../OCMock/OCMock.xcconfig | 9 +- .../ParseKit/ParseKit.xcconfig | 11 +- ...ds-AppledocTests-acknowledgements.markdown | 109 +- .../Pods-AppledocTests-acknowledgements.plist | 123 +- .../Pods-AppledocTests-dummy.m | 4 +- .../Pods-AppledocTests-frameworks.sh | 101 - .../Pods-AppledocTests-resources.sh | 112 - .../Pods-AppledocTests.debug.xcconfig | 12 +- .../Pods-AppledocTests.release.xcconfig | 12 +- .../Pods-appledoc-acknowledgements.markdown | 81 +- .../Pods-appledoc-acknowledgements.plist | 89 +- .../Pods-appledoc.debug.xcconfig | 12 +- .../Pods-appledoc.release.xcconfig | 12 +- .../RegexKitLite/RegexKitLite.xcconfig | 10 +- Processing/GBCommentsProcessor.m | 63 +- Processing/GBProcessor.m | 86 +- Testing/GBAdoptedProtocolsProviderTesting.m | 112 - .../GBApplicationSettingsProviderTesting.m | 673 --- Testing/GBApplicationTesting.m | 625 --- Testing/GBCategoryDataTesting.m | 113 - Testing/GBClassDataTesting.m | 123 - Testing/GBCommentComponentsListTesting.m | 52 - Testing/GBCommentComponentsProviderTesting.m | 24 - Testing/GBCommentTesting.m | 60 - Testing/GBCommentsProcessor-MarkdownTesting.m | 436 -- ...GBCommentsProcessor-PreprocessingTesting.m | 760 --- ...GBCommentsProcessor-RegistrationsTesting.m | 510 -- Testing/GBDocumentDataTesting.m | 83 - Testing/GBIvarDataTesting.m | 34 - Testing/GBIvarsProviderTesting.m | 102 - Testing/GBMethodDataTesting.m | 616 --- Testing/GBMethodsProviderTesting.m | 657 --- Testing/GBModelBaseTesting.m | 143 - ...veCParser-AdoptedProtocolsParsingTesting.m | 45 - ...BObjectiveCParser-CategoryParsingTesting.m | 475 -- .../GBObjectiveCParser-ClassParsingTesting.m | 383 -- .../GBObjectiveCParser-IvarsParsingTesting.m | 70 - ...GBObjectiveCParser-MethodsParsingTesting.m | 927 ---- ...BObjectiveCParser-ProtocolParsingTesting.m | 189 - ...BObjectiveCParser-SectionsParsingTesting.m | 119 - Testing/GBObjectsAssertor.h | 34 - Testing/GBObjectsAssertor.m | 223 - .../GBProcessor-CategoriesMergingTesting.m | 249 - Testing/GBProcessor-CommentsTesting.m | 223 - Testing/GBProcessor-KnownObjectsTesting.m | 244 - Testing/GBProcessor-MemberDocCopyingTesting.m | 159 - .../GBProcessor-UndocumentedObjectsTesting.m | 187 - Testing/GBProtocolDataTesting.m | 66 - Testing/GBStoreTesting.m | 400 -- Testing/GBTemplateHandlerTesting.m | 256 - ...BTemplateVariablesProvider-CommonTesting.m | 59 - ...blesProvider-ObjectSpecificationsTesting.m | 209 - Testing/GBTokenizerTesting.m | 475 -- Testing/GHUnitTestMain.m | 59 - appledoc.xcodeproj/project.pbxproj | 1187 +++-- .../xcshareddata/xcschemes/appledoc.xcscheme | 38 +- .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../GBApplicationSettingsProviderTesting.m | 681 +++ .../Application/GBApplicationTesting.m | 641 +++ .../GBCommentComponentsProviderTesting.m | 35 + .../GBRealLifeDataProvider.h | 0 .../GBRealLifeDataProvider.m | 0 .../GBTestObjectsRegistry.h | 2 + .../GBTestObjectsRegistry.m | 0 .../Generating/GBTemplateHandlerTesting.m | 266 + ...BTemplateVariablesProvider-CommonTesting.m | 76 + ...blesProvider-ObjectSpecificationsTesting.m | 221 + .../Info.plist | 12 +- .../Model/GBAdoptedProtocolsProviderTesting.m | 125 + appledocTests/Model/GBCategoryDataTesting.m | 126 + appledocTests/Model/GBClassDataTesting.m | 139 + .../Model/GBCommentComponentsListTesting.m | 64 + appledocTests/Model/GBCommentTesting.m | 73 + appledocTests/Model/GBDocumentDataTesting.m | 94 + appledocTests/Model/GBIvarDataTesting.m | 46 + appledocTests/Model/GBIvarsProviderTesting.m | 117 + appledocTests/Model/GBMethodDataTesting.m | 617 +++ .../Model/GBMethodsProviderTesting.m | 667 +++ appledocTests/Model/GBModelBaseTesting.m | 153 + appledocTests/Model/GBProtocolDataTesting.m | 80 + appledocTests/Model/GBStoreTesting.m | 414 ++ ...veCParser-AdoptedProtocolsParsingTesting.m | 57 + ...BObjectiveCParser-CategoryParsingTesting.m | 488 ++ .../GBObjectiveCParser-ClassParsingTesting.m | 394 ++ .../GBObjectiveCParser-IvarsParsingTesting.m | 81 + ...GBObjectiveCParser-MethodsParsingTesting.m | 1026 ++++ ...BObjectiveCParser-ProtocolParsingTesting.m | 202 + ...BObjectiveCParser-SectionsParsingTesting.m | 135 + appledocTests/Parsing/GBTokenizerTesting.m | 486 ++ .../GObjectiveCParser-BlockParsingTesting.m | 59 +- .../GBCommentsProcessor-MarkdownTesting.m | 450 ++ ...GBCommentsProcessor-PreprocessingTesting.m | 769 +++ ...GBCommentsProcessor-RegistrationsTesting.m | 593 +++ .../GBProcessor-CategoriesMergingTesting.m | 260 + .../Processing/GBProcessor-CommentsTesting.m | 236 + .../GBProcessor-KnownObjectsTesting.m | 256 + .../GBProcessor-MemberDocCopyingTesting.m | 170 + .../GBProcessor-UndocumentedObjectsTesting.m | 200 + appledoc_Prefix.pch | 2 +- default.profraw | Bin 0 -> 214472 bytes 364 files changed, 21538 insertions(+), 30410 deletions(-) delete mode 100644 AppledocTests_prefix.pch delete mode 100755 Common/ThirdParty/CocoaLumberjack/DDASLLogger.m delete mode 100644 Common/ThirdParty/CocoaLumberjack/DDFileLogger.h delete mode 100644 Common/ThirdParty/CocoaLumberjack/DDFileLogger.m delete mode 100755 Common/ThirdParty/CocoaLumberjack/DDLog.h delete mode 100755 Common/ThirdParty/CocoaLumberjack/DDLog.m delete mode 100755 Common/ThirdParty/CocoaLumberjack/DDTTYLogger.h delete mode 100755 Common/ThirdParty/CocoaLumberjack/DDTTYLogger.m rename {Pods/Minizip => Common/ThirdParty/DDMinizip/minizip}/LICENSE (100%) rename {Pods/Minizip => Common/ThirdParty/DDMinizip/minizip}/crypt.c (100%) rename {Pods/Minizip => Common/ThirdParty/DDMinizip/minizip}/crypt.h (100%) rename {Pods/Minizip => Common/ThirdParty/DDMinizip/minizip}/ioapi.c (100%) rename {Pods/Minizip => Common/ThirdParty/DDMinizip/minizip}/ioapi.h (100%) rename {Pods/Minizip => Common/ThirdParty/DDMinizip/minizip}/ioapi_buf.c (95%) rename {Pods/Minizip => Common/ThirdParty/DDMinizip/minizip}/ioapi_buf.h (100%) rename {Pods/Minizip => Common/ThirdParty/DDMinizip/minizip}/ioapi_mem.c (100%) rename {Pods/Minizip => Common/ThirdParty/DDMinizip/minizip}/ioapi_mem.h (100%) rename {Pods/Minizip => Common/ThirdParty/DDMinizip/minizip}/minishared.c (100%) rename {Pods/Minizip => Common/ThirdParty/DDMinizip/minizip}/minishared.h (100%) rename {Pods/Minizip => Common/ThirdParty/DDMinizip/minizip}/unzip.c (100%) rename {Pods/Minizip => Common/ThirdParty/DDMinizip/minizip}/unzip.h (100%) rename {Pods/Minizip => Common/ThirdParty/DDMinizip/minizip}/zip.c (100%) rename {Pods/Minizip => Common/ThirdParty/DDMinizip/minizip}/zip.h (100%) rename {Pods => Common/ThirdParty}/DDMinizip/src/DDZipReader.h (100%) rename {Pods => Common/ThirdParty}/DDMinizip/src/DDZipReader.m (100%) rename {Pods => Common/ThirdParty}/DDMinizip/src/DDZipWriter.h (100%) rename {Pods => Common/ThirdParty}/DDMinizip/src/DDZipWriter.m (100%) rename {Pods => Common/ThirdParty}/DDMinizip/src/DDZippedFileInfo.h (100%) rename {Pods => Common/ThirdParty}/DDMinizip/src/DDZippedFileInfo.m (100%) create mode 100644 Pods/CocoaLumberjack/LICENSE.txt create mode 100644 Pods/CocoaLumberjack/Lumberjack/DDASLLogCapture.h create mode 100644 Pods/CocoaLumberjack/Lumberjack/DDASLLogCapture.m rename {Common/ThirdParty/CocoaLumberjack => Pods/CocoaLumberjack/Lumberjack}/DDASLLogger.h (76%) create mode 100755 Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m create mode 100644 Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h create mode 100644 Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m create mode 100644 Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h create mode 100644 Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m create mode 100644 Pods/CocoaLumberjack/Lumberjack/DDLog+LOGV.h create mode 100755 Pods/CocoaLumberjack/Lumberjack/DDLog.h create mode 100755 Pods/CocoaLumberjack/Lumberjack/DDLog.m create mode 100755 Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h create mode 100755 Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m create mode 100644 Pods/CocoaLumberjack/Lumberjack/Extensions/DDContextFilterLogFormatter.h create mode 100644 Pods/CocoaLumberjack/Lumberjack/Extensions/DDContextFilterLogFormatter.m create mode 100644 Pods/CocoaLumberjack/Lumberjack/Extensions/DDDispatchQueueLogFormatter.h create mode 100644 Pods/CocoaLumberjack/Lumberjack/Extensions/DDDispatchQueueLogFormatter.m create mode 100644 Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.h create mode 100644 Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.m create mode 100644 Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt create mode 100644 Pods/CocoaLumberjack/README.markdown delete mode 100644 Pods/DDMinizip/LICENSE.rtf delete mode 100644 Pods/DDMinizip/README.md delete mode 100644 Pods/GHUnit/Classes-MacOSX/UI/GHTestApp.h delete mode 100644 Pods/GHUnit/Classes-MacOSX/UI/GHTestApp.m delete mode 100644 Pods/GHUnit/Classes-MacOSX/UI/GHTestApp.xib delete mode 100644 Pods/GHUnit/Classes-MacOSX/UI/GHTestOutlineViewModel.h delete mode 100644 Pods/GHUnit/Classes-MacOSX/UI/GHTestOutlineViewModel.m delete mode 100644 Pods/GHUnit/Classes-MacOSX/UI/GHTestView.xib delete mode 100644 Pods/GHUnit/Classes-MacOSX/UI/GHTestViewController.h delete mode 100644 Pods/GHUnit/Classes-MacOSX/UI/GHTestViewController.m delete mode 100644 Pods/GHUnit/Classes-MacOSX/UI/GHTestWindow.xib delete mode 100644 Pods/GHUnit/Classes-MacOSX/UI/GHTestWindowController.h delete mode 100644 Pods/GHUnit/Classes-MacOSX/UI/GHTestWindowController.m delete mode 100644 Pods/GHUnit/Classes/GHAsyncTestCase.h delete mode 100644 Pods/GHUnit/Classes/GHAsyncTestCase.m delete mode 100644 Pods/GHUnit/Classes/GHTest/GHTest+JUnitXML.h delete mode 100644 Pods/GHUnit/Classes/GHTest/GHTest+JUnitXML.m delete mode 100644 Pods/GHUnit/Classes/GHTest/GHTest.h delete mode 100644 Pods/GHUnit/Classes/GHTest/GHTest.m delete mode 100644 Pods/GHUnit/Classes/GHTest/GHTestGroup+JUnitXML.h delete mode 100644 Pods/GHUnit/Classes/GHTest/GHTestGroup+JUnitXML.m delete mode 100644 Pods/GHUnit/Classes/GHTest/GHTestGroup.h delete mode 100644 Pods/GHUnit/Classes/GHTest/GHTestGroup.m delete mode 100644 Pods/GHUnit/Classes/GHTest/GHTestOperation.h delete mode 100644 Pods/GHUnit/Classes/GHTest/GHTestOperation.m delete mode 100644 Pods/GHUnit/Classes/GHTest/GHTestRunner.h delete mode 100644 Pods/GHUnit/Classes/GHTest/GHTestRunner.m delete mode 100644 Pods/GHUnit/Classes/GHTest/GHTestSuite.h delete mode 100644 Pods/GHUnit/Classes/GHTest/GHTestSuite.m delete mode 100644 Pods/GHUnit/Classes/GHTest/GHTesting.h delete mode 100644 Pods/GHUnit/Classes/GHTest/GHTesting.m delete mode 100644 Pods/GHUnit/Classes/GHTest/NSException+GHTestFailureExceptions.h delete mode 100644 Pods/GHUnit/Classes/GHTest/NSException+GHTestFailureExceptions.m delete mode 100644 Pods/GHUnit/Classes/GHTest/NSValue+GHValueFormatter.h delete mode 100644 Pods/GHUnit/Classes/GHTest/NSValue+GHValueFormatter.m delete mode 100644 Pods/GHUnit/Classes/GHTestCase.h delete mode 100644 Pods/GHUnit/Classes/GHTestCase.m delete mode 100644 Pods/GHUnit/Classes/GHTestMacros.h delete mode 100644 Pods/GHUnit/Classes/GHTestUtils.h delete mode 100644 Pods/GHUnit/Classes/GHTestUtils.m delete mode 100644 Pods/GHUnit/Classes/GHUnit.h delete mode 100644 Pods/GHUnit/Classes/Mock/GHMockNSHTTPURLResponse.h delete mode 100644 Pods/GHUnit/Classes/Mock/GHMockNSHTTPURLResponse.m delete mode 100644 Pods/GHUnit/Classes/Mock/GHMockNSURLConnection.h delete mode 100644 Pods/GHUnit/Classes/Mock/GHMockNSURLConnection.m delete mode 100644 Pods/GHUnit/Classes/SharedUI/GHTestViewModel.h delete mode 100644 Pods/GHUnit/Classes/SharedUI/GHTestViewModel.m delete mode 100644 Pods/GHUnit/LICENSE delete mode 100644 Pods/GHUnit/Libraries/GTM/Foundation/GTMNSString+XML.h delete mode 100644 Pods/GHUnit/Libraries/GTM/Foundation/GTMNSString+XML.m delete mode 100644 Pods/GHUnit/Libraries/GTM/Foundation/GTMObjC2Runtime.h delete mode 100644 Pods/GHUnit/Libraries/GTM/Foundation/GTMObjC2Runtime.m delete mode 100644 Pods/GHUnit/Libraries/GTM/GTMDefines.h delete mode 100644 Pods/GHUnit/README.md create mode 120000 Pods/Headers/Private/CocoaLumberjack/DDASLLogCapture.h create mode 120000 Pods/Headers/Private/CocoaLumberjack/DDASLLogger.h create mode 120000 Pods/Headers/Private/CocoaLumberjack/DDAbstractDatabaseLogger.h create mode 120000 Pods/Headers/Private/CocoaLumberjack/DDContextFilterLogFormatter.h create mode 120000 Pods/Headers/Private/CocoaLumberjack/DDDispatchQueueLogFormatter.h create mode 120000 Pods/Headers/Private/CocoaLumberjack/DDFileLogger.h create mode 120000 Pods/Headers/Private/CocoaLumberjack/DDLog+LOGV.h create mode 120000 Pods/Headers/Private/CocoaLumberjack/DDLog.h create mode 120000 Pods/Headers/Private/CocoaLumberjack/DDMultiFormatter.h create mode 120000 Pods/Headers/Private/CocoaLumberjack/DDTTYLogger.h delete mode 120000 Pods/Headers/Private/DDMinizip/DDZipReader.h delete mode 120000 Pods/Headers/Private/DDMinizip/DDZipWriter.h delete mode 120000 Pods/Headers/Private/DDMinizip/DDZippedFileInfo.h delete mode 120000 Pods/Headers/Private/GHUnit/GHAsyncTestCase.h delete mode 120000 Pods/Headers/Private/GHUnit/GHMockNSHTTPURLResponse.h delete mode 120000 Pods/Headers/Private/GHUnit/GHMockNSURLConnection.h delete mode 120000 Pods/Headers/Private/GHUnit/GHTest+JUnitXML.h delete mode 120000 Pods/Headers/Private/GHUnit/GHTest.h delete mode 120000 Pods/Headers/Private/GHUnit/GHTestApp.h delete mode 120000 Pods/Headers/Private/GHUnit/GHTestCase.h delete mode 120000 Pods/Headers/Private/GHUnit/GHTestGroup+JUnitXML.h delete mode 120000 Pods/Headers/Private/GHUnit/GHTestGroup.h delete mode 120000 Pods/Headers/Private/GHUnit/GHTestMacros.h delete mode 120000 Pods/Headers/Private/GHUnit/GHTestOperation.h delete mode 120000 Pods/Headers/Private/GHUnit/GHTestOutlineViewModel.h delete mode 120000 Pods/Headers/Private/GHUnit/GHTestRunner.h delete mode 120000 Pods/Headers/Private/GHUnit/GHTestSuite.h delete mode 120000 Pods/Headers/Private/GHUnit/GHTestUtils.h delete mode 120000 Pods/Headers/Private/GHUnit/GHTestViewController.h delete mode 120000 Pods/Headers/Private/GHUnit/GHTestViewModel.h delete mode 120000 Pods/Headers/Private/GHUnit/GHTestWindowController.h delete mode 120000 Pods/Headers/Private/GHUnit/GHTesting.h delete mode 120000 Pods/Headers/Private/GHUnit/GHUnit.h delete mode 120000 Pods/Headers/Private/GHUnit/GTMDefines.h delete mode 120000 Pods/Headers/Private/GHUnit/GTMNSString+XML.h delete mode 120000 Pods/Headers/Private/GHUnit/GTMObjC2Runtime.h delete mode 120000 Pods/Headers/Private/GHUnit/NSException+GHTestFailureExceptions.h delete mode 120000 Pods/Headers/Private/GHUnit/NSValue+GHValueFormatter.h delete mode 120000 Pods/Headers/Private/Minizip/crypt.h delete mode 120000 Pods/Headers/Private/Minizip/ioapi.h delete mode 120000 Pods/Headers/Private/Minizip/ioapi_buf.h delete mode 120000 Pods/Headers/Private/Minizip/ioapi_mem.h delete mode 120000 Pods/Headers/Private/Minizip/minishared.h delete mode 120000 Pods/Headers/Private/Minizip/unzip.h delete mode 120000 Pods/Headers/Private/Minizip/zip.h create mode 120000 Pods/Headers/Public/CocoaLumberjack/DDASLLogCapture.h create mode 120000 Pods/Headers/Public/CocoaLumberjack/DDASLLogger.h create mode 120000 Pods/Headers/Public/CocoaLumberjack/DDAbstractDatabaseLogger.h create mode 120000 Pods/Headers/Public/CocoaLumberjack/DDContextFilterLogFormatter.h create mode 120000 Pods/Headers/Public/CocoaLumberjack/DDDispatchQueueLogFormatter.h create mode 120000 Pods/Headers/Public/CocoaLumberjack/DDFileLogger.h create mode 120000 Pods/Headers/Public/CocoaLumberjack/DDLog+LOGV.h create mode 120000 Pods/Headers/Public/CocoaLumberjack/DDLog.h create mode 120000 Pods/Headers/Public/CocoaLumberjack/DDMultiFormatter.h create mode 120000 Pods/Headers/Public/CocoaLumberjack/DDTTYLogger.h delete mode 120000 Pods/Headers/Public/DDMinizip/DDZipReader.h delete mode 120000 Pods/Headers/Public/DDMinizip/DDZipWriter.h delete mode 120000 Pods/Headers/Public/DDMinizip/DDZippedFileInfo.h delete mode 120000 Pods/Headers/Public/GHUnit/GHAsyncTestCase.h delete mode 120000 Pods/Headers/Public/GHUnit/GHMockNSHTTPURLResponse.h delete mode 120000 Pods/Headers/Public/GHUnit/GHMockNSURLConnection.h delete mode 120000 Pods/Headers/Public/GHUnit/GHTest+JUnitXML.h delete mode 120000 Pods/Headers/Public/GHUnit/GHTest.h delete mode 120000 Pods/Headers/Public/GHUnit/GHTestApp.h delete mode 120000 Pods/Headers/Public/GHUnit/GHTestCase.h delete mode 120000 Pods/Headers/Public/GHUnit/GHTestGroup+JUnitXML.h delete mode 120000 Pods/Headers/Public/GHUnit/GHTestGroup.h delete mode 120000 Pods/Headers/Public/GHUnit/GHTestMacros.h delete mode 120000 Pods/Headers/Public/GHUnit/GHTestOperation.h delete mode 120000 Pods/Headers/Public/GHUnit/GHTestOutlineViewModel.h delete mode 120000 Pods/Headers/Public/GHUnit/GHTestRunner.h delete mode 120000 Pods/Headers/Public/GHUnit/GHTestSuite.h delete mode 120000 Pods/Headers/Public/GHUnit/GHTestUtils.h delete mode 120000 Pods/Headers/Public/GHUnit/GHTestViewController.h delete mode 120000 Pods/Headers/Public/GHUnit/GHTestViewModel.h delete mode 120000 Pods/Headers/Public/GHUnit/GHTestWindowController.h delete mode 120000 Pods/Headers/Public/GHUnit/GHTesting.h delete mode 120000 Pods/Headers/Public/GHUnit/GHUnit.h delete mode 120000 Pods/Headers/Public/GHUnit/GTMDefines.h delete mode 120000 Pods/Headers/Public/GHUnit/GTMNSString+XML.h delete mode 120000 Pods/Headers/Public/GHUnit/GTMObjC2Runtime.h delete mode 120000 Pods/Headers/Public/GHUnit/NSException+GHTestFailureExceptions.h delete mode 120000 Pods/Headers/Public/GHUnit/NSValue+GHValueFormatter.h delete mode 120000 Pods/Headers/Public/Minizip/crypt.h delete mode 120000 Pods/Headers/Public/Minizip/ioapi.h delete mode 120000 Pods/Headers/Public/Minizip/ioapi_buf.h delete mode 120000 Pods/Headers/Public/Minizip/ioapi_mem.h delete mode 120000 Pods/Headers/Public/Minizip/minishared.h delete mode 120000 Pods/Headers/Public/Minizip/unzip.h delete mode 120000 Pods/Headers/Public/Minizip/zip.h delete mode 100644 Pods/Local Podspecs/DDMinizip.podspec.json delete mode 100644 Pods/Local Podspecs/Minizip.podspec.json delete mode 100644 Pods/Minizip/README.md create mode 100644 Pods/Target Support Files/CocoaLumberjack/CocoaLumberjack-dummy.m rename Pods/Target Support Files/{DDMinizip/DDMinizip-prefix.pch => CocoaLumberjack/CocoaLumberjack-prefix.pch} (100%) create mode 100644 Pods/Target Support Files/CocoaLumberjack/CocoaLumberjack.xcconfig delete mode 100644 Pods/Target Support Files/DDMinizip/DDMinizip-dummy.m delete mode 100644 Pods/Target Support Files/DDMinizip/DDMinizip.xcconfig delete mode 100644 Pods/Target Support Files/GHUnit/GHUnit-dummy.m delete mode 100644 Pods/Target Support Files/GHUnit/GHUnit-prefix.pch delete mode 100644 Pods/Target Support Files/GHUnit/GHUnit.xcconfig delete mode 100644 Pods/Target Support Files/Minizip/Minizip-dummy.m delete mode 100644 Pods/Target Support Files/Minizip/Minizip-prefix.pch delete mode 100644 Pods/Target Support Files/Minizip/Minizip.xcconfig delete mode 100755 Pods/Target Support Files/Pods-AppledocTests/Pods-AppledocTests-frameworks.sh delete mode 100755 Pods/Target Support Files/Pods-AppledocTests/Pods-AppledocTests-resources.sh delete mode 100644 Testing/GBAdoptedProtocolsProviderTesting.m delete mode 100644 Testing/GBApplicationSettingsProviderTesting.m delete mode 100644 Testing/GBApplicationTesting.m delete mode 100644 Testing/GBCategoryDataTesting.m delete mode 100644 Testing/GBClassDataTesting.m delete mode 100644 Testing/GBCommentComponentsListTesting.m delete mode 100644 Testing/GBCommentComponentsProviderTesting.m delete mode 100644 Testing/GBCommentTesting.m delete mode 100644 Testing/GBCommentsProcessor-MarkdownTesting.m delete mode 100644 Testing/GBCommentsProcessor-PreprocessingTesting.m delete mode 100644 Testing/GBCommentsProcessor-RegistrationsTesting.m delete mode 100644 Testing/GBDocumentDataTesting.m delete mode 100644 Testing/GBIvarDataTesting.m delete mode 100644 Testing/GBIvarsProviderTesting.m delete mode 100644 Testing/GBMethodDataTesting.m delete mode 100644 Testing/GBMethodsProviderTesting.m delete mode 100644 Testing/GBModelBaseTesting.m delete mode 100644 Testing/GBObjectiveCParser-AdoptedProtocolsParsingTesting.m delete mode 100644 Testing/GBObjectiveCParser-CategoryParsingTesting.m delete mode 100644 Testing/GBObjectiveCParser-ClassParsingTesting.m delete mode 100644 Testing/GBObjectiveCParser-IvarsParsingTesting.m delete mode 100644 Testing/GBObjectiveCParser-MethodsParsingTesting.m delete mode 100644 Testing/GBObjectiveCParser-ProtocolParsingTesting.m delete mode 100644 Testing/GBObjectiveCParser-SectionsParsingTesting.m delete mode 100644 Testing/GBObjectsAssertor.h delete mode 100644 Testing/GBObjectsAssertor.m delete mode 100644 Testing/GBProcessor-CategoriesMergingTesting.m delete mode 100644 Testing/GBProcessor-CommentsTesting.m delete mode 100644 Testing/GBProcessor-KnownObjectsTesting.m delete mode 100644 Testing/GBProcessor-MemberDocCopyingTesting.m delete mode 100644 Testing/GBProcessor-UndocumentedObjectsTesting.m delete mode 100644 Testing/GBProtocolDataTesting.m delete mode 100644 Testing/GBStoreTesting.m delete mode 100644 Testing/GBTemplateHandlerTesting.m delete mode 100644 Testing/GBTemplateVariablesProvider-CommonTesting.m delete mode 100644 Testing/GBTemplateVariablesProvider-ObjectSpecificationsTesting.m delete mode 100644 Testing/GBTokenizerTesting.m delete mode 100644 Testing/GHUnitTestMain.m create mode 100644 appledoc.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 appledocTests/Application/GBApplicationSettingsProviderTesting.m create mode 100644 appledocTests/Application/GBApplicationTesting.m create mode 100644 appledocTests/Application/GBCommentComponentsProviderTesting.m rename {Testing => appledocTests/Creation & Assertion}/GBRealLifeDataProvider.h (100%) rename {Testing => appledocTests/Creation & Assertion}/GBRealLifeDataProvider.m (100%) rename {Testing => appledocTests/Creation & Assertion}/GBTestObjectsRegistry.h (96%) rename {Testing => appledocTests/Creation & Assertion}/GBTestObjectsRegistry.m (100%) create mode 100644 appledocTests/Generating/GBTemplateHandlerTesting.m create mode 100644 appledocTests/Generating/GBTemplateVariablesProvider-CommonTesting.m create mode 100644 appledocTests/Generating/GBTemplateVariablesProvider-ObjectSpecificationsTesting.m rename AppledocTests-Info.plist => appledocTests/Info.plist (71%) create mode 100644 appledocTests/Model/GBAdoptedProtocolsProviderTesting.m create mode 100644 appledocTests/Model/GBCategoryDataTesting.m create mode 100644 appledocTests/Model/GBClassDataTesting.m create mode 100644 appledocTests/Model/GBCommentComponentsListTesting.m create mode 100644 appledocTests/Model/GBCommentTesting.m create mode 100644 appledocTests/Model/GBDocumentDataTesting.m create mode 100644 appledocTests/Model/GBIvarDataTesting.m create mode 100644 appledocTests/Model/GBIvarsProviderTesting.m create mode 100644 appledocTests/Model/GBMethodDataTesting.m create mode 100644 appledocTests/Model/GBMethodsProviderTesting.m create mode 100644 appledocTests/Model/GBModelBaseTesting.m create mode 100644 appledocTests/Model/GBProtocolDataTesting.m create mode 100644 appledocTests/Model/GBStoreTesting.m create mode 100644 appledocTests/Parsing/GBObjectiveCParser-AdoptedProtocolsParsingTesting.m create mode 100644 appledocTests/Parsing/GBObjectiveCParser-CategoryParsingTesting.m create mode 100644 appledocTests/Parsing/GBObjectiveCParser-ClassParsingTesting.m create mode 100644 appledocTests/Parsing/GBObjectiveCParser-IvarsParsingTesting.m create mode 100644 appledocTests/Parsing/GBObjectiveCParser-MethodsParsingTesting.m create mode 100644 appledocTests/Parsing/GBObjectiveCParser-ProtocolParsingTesting.m create mode 100644 appledocTests/Parsing/GBObjectiveCParser-SectionsParsingTesting.m create mode 100644 appledocTests/Parsing/GBTokenizerTesting.m rename {Testing => appledocTests/Parsing}/GObjectiveCParser-BlockParsingTesting.m (59%) create mode 100644 appledocTests/Processing/GBCommentsProcessor-MarkdownTesting.m create mode 100644 appledocTests/Processing/GBCommentsProcessor-PreprocessingTesting.m create mode 100644 appledocTests/Processing/GBCommentsProcessor-RegistrationsTesting.m create mode 100644 appledocTests/Processing/GBProcessor-CategoriesMergingTesting.m create mode 100644 appledocTests/Processing/GBProcessor-CommentsTesting.m create mode 100644 appledocTests/Processing/GBProcessor-KnownObjectsTesting.m create mode 100644 appledocTests/Processing/GBProcessor-MemberDocCopyingTesting.m create mode 100644 appledocTests/Processing/GBProcessor-UndocumentedObjectsTesting.m create mode 100644 default.profraw diff --git a/AppledocTests_prefix.pch b/AppledocTests_prefix.pch deleted file mode 100644 index d5d4fd60..00000000 --- a/AppledocTests_prefix.pch +++ /dev/null @@ -1,27 +0,0 @@ -// -// AppledocTests_prefix.pch -// appledoc -// -// Created by Tomaz Kragelj on 22.7.10. -// Copyright (C) 2010, Gentle Bytes. All rights reserved. -// - -#ifdef __OBJC__ - #import - #import "NSObject+GBObject.h" - #import "NSString+GBString.h" - #import "NSArray+GBArray.h" - #import "NSException+GBException.h" - #import "NSError+GBError.h" - #import "NSFileManager+GBFileManager.h" - #import "GBLog.h" - #import "GBExitCodes.h" - - #define HC_SHORTHAND - #import - #import - #import - #import "GBRealLifeDataProvider.h" - #import "GBTestObjectsRegistry.h" - #import "GBObjectsAssertor.h" -#endif diff --git a/Application/GBAppledocApplication.h b/Application/GBAppledocApplication.h index 35d0a2de..d2d02f77 100644 --- a/Application/GBAppledocApplication.h +++ b/Application/GBAppledocApplication.h @@ -21,4 +21,6 @@ */ @interface GBAppledocApplication : NSObject +- (NSString *)standardizeCurrentDirectoryForPath:(NSString *)path; + @end diff --git a/Application/GBAppledocApplication.m b/Application/GBAppledocApplication.m index 108f298b..ed18e493 100644 --- a/Application/GBAppledocApplication.m +++ b/Application/GBAppledocApplication.m @@ -18,6 +18,14 @@ #import "DDXcodeProjectFile.h" #import "DDEmbeddedDataReader.h" #import "DDZipReader.h" +#import "GBExitCodes.h" +//#import "GBLog.h" +#import "NSObject+GBObject.h" +#import "NSException+GBException.h" +#import "NSString+GBString.h" +#import "NSError+GBError.h" + +//extern NSInteger kGBLogBasedResult; static char *kGBArgInputPath = "input"; static char *kGBArgOutputPath = "output"; @@ -185,53 +193,53 @@ - (int)application:(DDCliApplication *)app runWithArguments:(NSArray *)arguments [self validateSettingsAndArguments:inputs]; [self.settings replaceAllOccurencesOfPlaceholderStringsInSettingsValues]; if (self.printSettings) [self printSettingsAndArguments:inputs]; - kGBLogBasedResult = GBEXIT_SUCCESS; +// kGBLogBasedResult = GBEXIT_SUCCESS; @try { [self initializeLoggingSystem]; [self deleteContentsOfOutputPath]; - GBLogNormal(@"Initializing..."); +// GBLogNormal(@"Initializing..."); GBStore *store = [[GBStore alloc] init]; - GBAbsoluteTime startTime = GetCurrentTime(); +// GBAbsoluteTime startTime = GetCurrentTime(); - GBLogNormal(@"Parsing source files..."); +// GBLogNormal(@"Parsing source files..."); GBParser *parser = [GBParser parserWithSettingsProvider:self.settings]; [parser parseObjectsFromPaths:inputs toStore:store]; [parser parseDocumentsFromPaths:[self.settings.includePaths allObjects] toStore:store]; [parser parseCustomDocumentFromPath:self.settings.indexDescriptionPath outputSubpath:@"" key:kGBCustomDocumentIndexDescKey toStore:store]; - GBAbsoluteTime parseTime = GetCurrentTime(); - NSUInteger timeForParsing = SubtractTime(parseTime, startTime) * 1000.0; - GBLogInfo(@"Finished parsing in %ldms.\n", timeForParsing); +// GBAbsoluteTime parseTime = GetCurrentTime(); +// NSUInteger timeForParsing = SubtractTime(parseTime, startTime) * 1000.0; +// GBLogInfo(@"Finished parsing in %ldms.\n", timeForParsing); - GBLogNormal(@"Processing parsed data..."); +// GBLogNormal(@"Processing parsed data..."); GBProcessor *processor = [GBProcessor processorWithSettingsProvider:self.settings]; [processor processObjectsFromStore:store]; - GBAbsoluteTime processTime = GetCurrentTime(); - NSUInteger timeForProcessing = SubtractTime(processTime, parseTime) * 1000.0; - GBLogInfo(@"Finished processing in %ldms.\n", timeForProcessing); +// GBAbsoluteTime processTime = GetCurrentTime(); +// NSUInteger timeForProcessing = SubtractTime(processTime, parseTime) * 1000.0; +// GBLogInfo(@"Finished processing in %ldms.\n", timeForProcessing); - GBLogNormal(@"Generating output..."); +// GBLogNormal(@"Generating output..."); GBGenerator *generator = [GBGenerator generatorWithSettingsProvider:self.settings]; [generator generateOutputFromStore:store]; - GBAbsoluteTime generateTime = GetCurrentTime(); - NSUInteger timeForGeneration = SubtractTime(generateTime, processTime) * 1000.0; - GBLogInfo(@"Finished generating in %ldms.\n", timeForGeneration); +// GBAbsoluteTime generateTime = GetCurrentTime(); +// NSUInteger timeForGeneration = SubtractTime(generateTime, processTime) * 1000.0; +// GBLogInfo(@"Finished generating in %ldms.\n", timeForGeneration); - NSUInteger timeForEverything = timeForParsing + timeForProcessing + timeForGeneration; - GBLogNormal(@"Finished in %ldms.", timeForEverything); - GBLogInfo(@"Parsing: %ldms (%ld%%)", timeForParsing, timeForParsing * 100 / timeForEverything); - GBLogInfo(@"Processing: %ldms (%ld%%)", timeForProcessing, timeForProcessing * 100 / timeForEverything); - GBLogInfo(@"Generating: %ldms (%ld%%)", timeForGeneration, timeForGeneration * 100 / timeForEverything); +// NSUInteger timeForEverything = timeForParsing + timeForProcessing + timeForGeneration; +// GBLogNormal(@"Finished in %ldms.", timeForEverything); +// GBLogInfo(@"Parsing: %ldms (%ld%%)", timeForParsing, timeForParsing * 100 / timeForEverything); +// GBLogInfo(@"Processing: %ldms (%ld%%)", timeForProcessing, timeForProcessing * 100 / timeForEverything); +// GBLogInfo(@"Generating: %ldms (%ld%%)", timeForGeneration, timeForGeneration * 100 / timeForEverything); } @catch (NSException *e) { - GBLogException(e, @"Oops, something went wrong..."); +// GBLogException(e, @"Oops, something went wrong..."); return GBEXIT_ASSERT_GENERIC; } - int result = (kGBLogBasedResult >= self.settings.exitCodeThreshold) ? kGBLogBasedResult : 0; - GBLogDebug(@"Exiting with result %d (reported result was %ld - higher than %d)...", result, kGBLogBasedResult, self.settings.exitCodeThreshold); - return result; +// int result = (kGBLogBasedResult >= self.settings.exitCodeThreshold) ? kGBLogBasedResult : 0; +// GBLogDebug(@"Exiting with result %d (reported result was %ld - higher than %d)...", result, kGBLogBasedResult, self.settings.exitCodeThreshold); + return GBEXIT_ASSERT_GENERIC; } - (void)application:(DDCliApplication *)app willParseOptions:(DDGetoptLongParser *)optionParser { @@ -354,10 +362,10 @@ - (void)application:(DDCliApplication *)app willParseOptions:(DDGetoptLongParser #pragma mark Application handling - (void)initializeLoggingSystem { - id formatter = [GBLog logFormatterForLogFormat:self.logformat]; - [[GBConsoleLogger sharedInstance] setLogFormatter:formatter]; - [DDLog addLogger:[GBConsoleLogger sharedInstance]]; - [GBLog setLogLevelFromVerbose:self.verbose]; +// id formatter = [GBLog logFormatterForLogFormat:self.logformat]; +// [[GBConsoleLogger sharedInstance] setLogFormatter:formatter]; +// [DDLog addLogger:[GBConsoleLogger sharedInstance]]; +// [GBLog setLogLevelFromVerbose:self.verbose]; } - (void)deleteContentsOfOutputPath { @@ -368,18 +376,18 @@ - (void)deleteContentsOfOutputPath { NSString *standardizedOutput = [outputPath stringByStandardizingPath]; NSError *error = nil; - GBLogInfo(@"Deleting contents of output path '%@'...", outputPath); +// GBLogInfo(@"Deleting contents of output path '%@'...", outputPath); NSArray *contents = [self.fileManager contentsOfDirectoryAtPath:standardizedOutput error:&error]; if (error) { - GBLogNSError(error, @"Failed enumerating contents of output path '%@'!, for cleaning up!", outputPath); +// GBLogNSError(error, @"Failed enumerating contents of output path '%@'!, for cleaning up!", outputPath); return; } for (NSString *subpath in contents) { - GBLogDebug(@"- Deleting '%@'...", subpath); +// GBLogDebug(@"- Deleting '%@'...", subpath); NSString *filename = [standardizedOutput stringByAppendingPathComponent:subpath]; if (![self.fileManager removeItemAtPath:filename error:&error] && error) { - GBLogNSError(error, @"Failed removing '%@' while cleaning up output!", filename); +// GBLogNSError(error, @"Failed removing '%@' while cleaning up output!", filename); } } } diff --git a/Application/GBApplicationSettingsProvider.m b/Application/GBApplicationSettingsProvider.m index d84ff4cf..cf34ffb5 100644 --- a/Application/GBApplicationSettingsProvider.m +++ b/Application/GBApplicationSettingsProvider.m @@ -12,7 +12,7 @@ #import #import "GBDataObjects.h" #import "GBApplicationSettingsProvider.h" -#import "GBLog.h" +//#import "GBLog.h" #import "SynthesizeSingleton.h" @@ -251,7 +251,7 @@ - (NSString *)stringByConvertingMarkdownToHTML:(NSString *)markdown { int size = mkd_document(document, &html); if (size <= 0) { - GBLogWarn(@"Failed converting markdown '%@' to HTML!", [markdown description]); +// GBLogWarn(@"Failed converting markdown '%@' to HTML!", [markdown description]); } else { result = [NSString stringWithCString:html encoding:NSUTF8StringEncoding]; if(!result) diff --git a/Common/GBLog.h b/Common/GBLog.h index 759be453..3aa3edbf 100644 --- a/Common/GBLog.h +++ b/Common/GBLog.h @@ -10,6 +10,7 @@ #import "DDTTYLogger.h" #import "DDFileLogger.h" #import "DDCliUtil.h" +#import "GBExitCodes.h" // Undefine defaults @@ -52,7 +53,10 @@ void GBLogUpdateResult(NSInteger result); #define LOG_FLAG_NORMAL (1 << 3) // 0...0001000 #define LOG_FLAG_INFO (1 << 4) // 0...0010000 #define LOG_FLAG_VERBOSE (1 << 5) // 0...0100000 +#ifdef LOG_FLAG_DEBUG +#undef LOG_FLAG_DEBUG #define LOG_FLAG_DEBUG (1 << 6) // 0...1000000 +#endif #define LOG_LEVEL_FATAL (LOG_FLAG_FATAL) // 0...0000001 #define LOG_LEVEL_ERROR (LOG_FLAG_ERROR | LOG_LEVEL_FATAL) // 0...0000011 @@ -60,7 +64,10 @@ void GBLogUpdateResult(NSInteger result); #define LOG_LEVEL_NORMAL (LOG_FLAG_NORMAL | LOG_LEVEL_WARN) // 0...0001111 #define LOG_LEVEL_INFO (LOG_FLAG_INFO | LOG_LEVEL_NORMAL) // 0...0011111 #define LOG_LEVEL_VERBOSE (LOG_FLAG_VERBOSE | LOG_LEVEL_INFO) // 0...0111111 +#ifdef LOG_LEVEL_DEBUG +#undef LOG_LEVEL_DEBUG #define LOG_LEVEL_DEBUG (LOG_FLAG_DEBUG | LOG_LEVEL_VERBOSE) // 0...1111111 +#endif #define SYNC_LOG_OBJC_MAYBE(lvl, flg, frmt, ...) LOG_MAYBE(YES, lvl, flg, __PRETTY_FUNCTION__, frmt, ##__VA_ARGS__) diff --git a/Common/GBLog.m b/Common/GBLog.m index e9b27165..30b77b41 100644 --- a/Common/GBLog.m +++ b/Common/GBLog.m @@ -162,20 +162,20 @@ - (NSString *)formatLogMessage:(DDLogMessage *)m { @implementation GBLogFormatXcodeFormatter - (NSString *)formatLogMessage:(DDLogMessage *)m { - if (m->originalFilename) { - NSString *level = nil; - switch (m->logFlag) { - case LOG_FLAG_FATAL: level = @"fatal"; break; - case LOG_FLAG_ERROR: level = @"error"; break; - case LOG_FLAG_WARN: level = @"warning"; break; - case LOG_FLAG_NORMAL: level = @"normal"; break; - case LOG_FLAG_INFO: level = @"info"; break; - case LOG_FLAG_VERBOSE: level = @"verbose"; break; - case LOG_FLAG_DEBUG: level = @"debug"; break; - default: level = @"unknown"; break; - } - return [NSString stringWithFormat:@"%@:%lu: %@: %@", m->originalFilename, m->originalLine, level, GBLogMessage(m)]; - } +// if (m->originalFilename) { +// NSString *level = nil; +// switch (m->logFlag) { +// case LOG_FLAG_FATAL: level = @"fatal"; break; +// case LOG_FLAG_ERROR: level = @"error"; break; +// case LOG_FLAG_WARN: level = @"warning"; break; +// case LOG_FLAG_NORMAL: level = @"normal"; break; +// case LOG_FLAG_INFO: level = @"info"; break; +// case LOG_FLAG_VERBOSE: level = @"verbose"; break; +// case LOG_FLAG_DEBUG: level = @"debug"; break; +// default: level = @"unknown"; break; +// } +// return [NSString stringWithFormat:@"%@:%lu: %@: %@", m->originalFilename, m->originalLine, level, GBLogMessage(m)]; +// } return GBLogMessage(m); } @end diff --git a/Common/GBTask.m b/Common/GBTask.m index f7287b66..0cab1874 100644 --- a/Common/GBTask.m +++ b/Common/GBTask.m @@ -53,7 +53,7 @@ - (BOOL)runCommand:(NSString *)command arguments:(NSArray *)arguments block:(GBT NSMutableString *commandLine = [NSMutableString string]; for (id argument in arguments) [commandLine appendFormat:@" %@", argument]; self.lastCommandLine = [NSString stringWithFormat:@"%@%@", command, commandLine]; - GBLogDebug(@"Running command '%@'", self.lastCommandLine); +// GBLogDebug(@"Running command '%@'", self.lastCommandLine); // Prepare deviation pipes so that we can extract the data from the task. If requested, prepare everything for continuous updating. NSPipe *stdOutPipe = [NSPipe pipe]; diff --git a/Common/ThirdParty/CocoaLumberjack/DDASLLogger.m b/Common/ThirdParty/CocoaLumberjack/DDASLLogger.m deleted file mode 100755 index d88f1929..00000000 --- a/Common/ThirdParty/CocoaLumberjack/DDASLLogger.m +++ /dev/null @@ -1,86 +0,0 @@ -#import "DDASLLogger.h" - -#import - - -@implementation DDASLLogger - -static DDASLLogger *sharedInstance; - -/** - * The runtime sends initialize to each class in a program exactly one time just before the class, - * or any class that inherits from it, is sent its first message from within the program. (Thus the - * method may never be invoked if the class is not used.) The runtime sends the initialize message to - * classes in a thread-safe manner. Superclasses receive this message before their subclasses. - * - * This method may also be called directly (assumably by accident), hence the safety mechanism. -**/ -+ (void)initialize -{ - static BOOL initialized = NO; - if (!initialized) - { - initialized = YES; - - sharedInstance = [[DDASLLogger alloc] init]; - } -} - -+ (DDASLLogger *)sharedInstance -{ - return sharedInstance; -} - -- (id)init -{ - if (sharedInstance != nil) - { - [self release]; - return nil; - } - - if ((self = [super init])) - { - // A default asl client is provided for the main thread, - // but background threads need to create their own client. - - client = asl_open(NULL, "com.apple.console", 0); - } - return self; -} - -- (void)logMessage:(DDLogMessage *)logMessage -{ - NSString *logMsg = logMessage->logMsg; - - if (formatter) - { - logMsg = [formatter formatLogMessage:logMessage]; - } - - if (logMsg) - { - const char *msg = [logMsg UTF8String]; - - int aslLogLevel; - switch (logMessage->logLevel) - { - // Note: By default ASL will filter anything above level 5 (Notice). - // So our mappings shouldn't go above that level. - - case 1 : aslLogLevel = ASL_LEVEL_CRIT; break; - case 2 : aslLogLevel = ASL_LEVEL_ERR; break; - case 3 : aslLogLevel = ASL_LEVEL_WARNING; break; - default : aslLogLevel = ASL_LEVEL_NOTICE; break; - } - - asl_log(client, NULL, aslLogLevel, "%s", msg); - } -} - -- (NSString *)loggerName -{ - return @"cocoa.lumberjack.aslLogger"; -} - -@end diff --git a/Common/ThirdParty/CocoaLumberjack/DDFileLogger.h b/Common/ThirdParty/CocoaLumberjack/DDFileLogger.h deleted file mode 100644 index 39c40bd2..00000000 --- a/Common/ThirdParty/CocoaLumberjack/DDFileLogger.h +++ /dev/null @@ -1,275 +0,0 @@ -#import -#import "DDLog.h" - -@class DDLogFileInfo; - - -// Default configuration and safety/sanity values. -// -// maximumFileSize -> DEFAULT_LOG_MAX_FILE_SIZE -// rollingFrequency -> DEFAULT_LOG_ROLLING_FREQUENCY -// maximumNumberOfLogFiles -> DEFAULT_LOG_MAX_NUM_LOG_FILES -// -// You should carefully consider the proper configuration values for your application. - -#define DEFAULT_LOG_MAX_FILE_SIZE (1024 * 1024) // 1 MB -#define DEFAULT_LOG_ROLLING_FREQUENCY (60 * 60 * 24) // 24 Hours -#define DEFAULT_LOG_MAX_NUM_LOG_FILES (5) // 5 Files - - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// The LogFileManager protocol is designed to allow you to control all aspects of your log files. -// -// The primary purpose of this is to allow you to do something with the log files after they have been rolled. -// Perhaps you want to compress them to save disk space. -// Perhaps you want to upload them to an FTP server. -// Perhaps you want to run some analytics on the file. -// -// A default LogFileManager is, of course, provided. -// The default LogFileManager simply deletes old log files according to the maximumNumberOfLogFiles property. -// -// This protocol provides various methods to fetch the list of log files. -// -// There are two variants: sorted and unsorted. -// If sorting is not necessary, the unsorted variant is obviously faster. -// The sorted variant will return an array sorted by when the log files were created, -// with the most recently created log file at index 0, and the oldest log file at the end of the array. -// -// You can fetch only the log file paths (full path including name), log file names (name only), -// or an array of DDLogFileInfo objects. -// The DDLogFileInfo class is documented below, and provides a handy wrapper that -// gives you easy access to various file attributes such as the creation date or the file size. - -@protocol DDLogFileManager -@required - -// Public properties - -@property (readwrite, assign) NSUInteger maximumNumberOfLogFiles; - -// Public methods - -- (NSString *)logsDirectory; - -- (NSArray *)unsortedLogFilePaths; -- (NSArray *)unsortedLogFileNames; -- (NSArray *)unsortedLogFileInfos; - -- (NSArray *)sortedLogFilePaths; -- (NSArray *)sortedLogFileNames; -- (NSArray *)sortedLogFileInfos; - -// Private methods (only to be used by DDFileLogger) - -- (NSString *)createNewLogFile; - -@optional - -// Notifications from DDFileLogger - -- (void)didArchiveLogFile:(NSString *)logFilePath; -- (void)didRollAndArchiveLogFile:(NSString *)logFilePath; - -@end - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// Default log file manager. -// -// All log files are placed inside the logsDirectory. -// On Mac, this is in ~/Library/Application Support//Logs. -// On iPhone, this is in ~/Documents/Logs. -// -// Log files are named "log-.txt", -// where uuid is a 6 character hexadecimal consisting of the set [0123456789ABCDEF]. -// -// Archived log files are automatically deleted according to the maximumNumberOfLogFiles property. - -@interface DDLogFileManagerDefault : NSObject -{ - NSUInteger maximumNumberOfLogFiles; -} - -@end - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// Most users will want file log messages to be prepended with the date and time. -// Rather than forcing the majority of users to write their own formatter, -// we will supply a logical default formatter. -// Users can easily replace this formatter with their own by invoking the setLogFormatter method. -// It can also be removed by calling setLogFormatter, and passing a nil parameter. -// -// In addition to the convenience of having a logical default formatter, -// it will also provide a template that makes it easy for developers to copy and change. - -@interface DDLogFileFormatterDefault : NSObject -{ - NSDateFormatter *dateFormatter; -} - -@end - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -@interface DDFileLogger : DDAbstractLogger -{ - id logFileManager; - - DDLogFileInfo *currentLogFileInfo; - NSFileHandle *currentLogFileHandle; - - NSTimer *rollingTimer; - - unsigned long long maximumFileSize; - NSTimeInterval rollingFrequency; -} - -- (id)init; -- (id)initWithLogFileManager:(id )logFileManager; - -// Configuration -// -// maximumFileSize: -// The approximate maximum size to allow log files to grow. -// If a log file is larger than this value after a write, -// then the log file is rolled. -// -// rollingFrequency -// How often to roll the log file. -// The frequency is given as an NSTimeInterval, which is a double that specifies the interval in seconds. -// Once the log file gets to be this old, it is rolled. -// -// Both the maximumFileSize and the rollingFrequency are used to manage rolling. -// Whichever occurs first will cause the log file to be rolled. -// -// For example: -// The rollingFrequency is 24 hours, -// but the log file surpasses the maximumFileSize after only 20 hours. -// The log file will be rolled at that 20 hour mark. -// A new log file will be created, and the 24 hour timer will be restarted. -// -// logFileManager -// Allows you to retrieve the list of log files, -// and configure the maximum number of archived log files to keep. - -@property (readwrite, assign) unsigned long long maximumFileSize; - -@property (readwrite, assign) NSTimeInterval rollingFrequency; - -@property (nonatomic, readonly) id logFileManager; - - -// You can optionally force the current log file to be rolled with this method. - -- (void)rollLogFile; - -// Inherited from DDAbstractLogger - -// - (id )logFormatter; -// - (void)setLogFormatter:(id )formatter; - -@end - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// DDLogFileInfo is a simple class that provides access to various file attributes. -// It provides good performance as it only fetches the information if requested, -// and it caches the information to prevent duplicate fetches. -// -// It was designed to provide quick snapshots of the current state of log files, -// and to help sort log files in an array. -// -// This class does not monitor the files, or update it's cached attribute values if the file changes on disk. -// This is not what the class was designed for. -// -// If you absolutely must get updated values, -// you can invoke the reset method which will clear the cache. - -@interface DDLogFileInfo : NSObject -{ - NSString *filePath; - NSString *fileName; - - NSDictionary *fileAttributes; - - NSDate *creationDate; - NSDate *modificationDate; - - unsigned long long fileSize; -} - -@property (nonatomic, readonly) NSString *filePath; -@property (nonatomic, readonly) NSString *fileName; - -@property (nonatomic, readonly) NSDictionary *fileAttributes; - -@property (nonatomic, readonly) NSDate *creationDate; -@property (nonatomic, readonly) NSDate *modificationDate; - -@property (nonatomic, readonly) unsigned long long fileSize; - -@property (nonatomic, readonly) NSTimeInterval age; - -@property (nonatomic, readwrite) BOOL isArchived; - -+ (id)logFileWithPath:(NSString *)filePath; - -- (id)initWithFilePath:(NSString *)filePath; - -- (void)reset; -- (void)renameFile:(NSString *)newFileName; - -#if TARGET_IPHONE_SIMULATOR - -// So here's the situation. -// Extended attributes are perfect for what we're trying to do here (marking files as archived). -// This is exactly what extended attributes were designed for. -// -// But Apple screws us over on the simulator. -// Everytime you build-and-go, they copy the application into a new folder on the hard drive, -// and as part of the process they strip extended attributes from our log files. -// Normally, a copy of a file preserves extended attributes. -// So obviously Apple has gone to great lengths to piss us off. -// -// Thus we use a slightly different tactic for marking log files as archived in the simulator. -// That way it "just works" and there's no confusion when testing. -// -// The difference in method names is indicative of the difference in functionality. -// On the simulator we add an attribute by appending a filename extension. -// -// For example: -// log-ABC123.txt -> log-ABC123.archived.txt - -- (BOOL)hasExtensionAttributeWithName:(NSString *)attrName; - -- (void)addExtensionAttributeWithName:(NSString *)attrName; -- (void)removeExtensionAttributeWithName:(NSString *)attrName; - -#else - -// Normal use of extended attributes used everywhere else, -// such as on Macs and on iPhone devices. - -- (BOOL)hasExtendedAttributeWithName:(NSString *)attrName; - -- (void)addExtendedAttributeWithName:(NSString *)attrName; -- (void)removeExtendedAttributeWithName:(NSString *)attrName; - -#endif - -- (NSComparisonResult)reverseCompareByCreationDate:(DDLogFileInfo *)another; -- (NSComparisonResult)reverseCompareByModificationDate:(DDLogFileInfo *)another; - -@end diff --git a/Common/ThirdParty/CocoaLumberjack/DDFileLogger.m b/Common/ThirdParty/CocoaLumberjack/DDFileLogger.m deleted file mode 100644 index 032ad5f1..00000000 --- a/Common/ThirdParty/CocoaLumberjack/DDFileLogger.m +++ /dev/null @@ -1,1469 +0,0 @@ -#import "DDFileLogger.h" - -#import -#import -#import -#import - -// We probably shouldn't be using DDLog() statements within the DDLog implementation. -// But we still want to leave our log statements for any future debugging, -// and to allow other developers to trace the implementation (which is a great learning tool). -// -// So we use primitive logging macros around NSLog. -// We maintain the NS prefix on the macros to be explicit about the fact that we're using NSLog. - -#define LOG_LEVEL 2 - -#define NSLogError(frmt, ...) do{ if(LOG_LEVEL >= 1) NSLog((frmt), ##__VA_ARGS__); } while(0) -#define NSLogWarn(frmt, ...) do{ if(LOG_LEVEL >= 2) NSLog((frmt), ##__VA_ARGS__); } while(0) -#define NSLogInfo(frmt, ...) do{ if(LOG_LEVEL >= 3) NSLog((frmt), ##__VA_ARGS__); } while(0) -#define NSLogVerbose(frmt, ...) do{ if(LOG_LEVEL >= 4) NSLog((frmt), ##__VA_ARGS__); } while(0) - -@interface DDLogFileManagerDefault (PrivateAPI) - -- (void)deleteOldLogFiles; - -@end - -@interface DDFileLogger (PrivateAPI) - -#if GCD_MAYBE_UNAVAILABLE - -- (void)lt_getMaximumFileSize:(NSMutableArray *)resultHolder; -- (void)lt_setMaximumFileSize:(NSNumber *)maximumFileSizeWrapper; - -- (void)lt_getRollingFrequency:(NSMutableArray *)resultHolder; -- (void)lt_setRollingFrequency:(NSNumber *)rollingFrequencyWrapper; - -#endif - -- (void)rollLogFileNow; -- (void)maybeRollLogFileDueToAge:(NSTimer *)aTimer; -- (void)maybeRollLogFileDueToSize; -@end - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -@implementation DDLogFileManagerDefault - -@synthesize maximumNumberOfLogFiles; - - -- (id)init -{ - if ((self = [super init])) - { - maximumNumberOfLogFiles = DEFAULT_LOG_MAX_NUM_LOG_FILES; - - NSKeyValueObservingOptions kvoOptions = NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew; - - [self addObserver:self forKeyPath:@"maximumNumberOfLogFiles" options:kvoOptions context:nil]; - - NSLogVerbose(@"DDFileLogManagerDefault: logsDir:\n%@", [self logsDirectory]); - NSLogVerbose(@"DDFileLogManagerDefault: sortedLogFileNames:\n%@", [self sortedLogFileNames]); - } - return self; -} - -- (void)dealloc -{ - [super dealloc]; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark Configuration -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -- (void)observeValueForKeyPath:(NSString *)keyPath - ofObject:(id)object - change:(NSDictionary *)change - context:(void *)context -{ - NSNumber *old = [change objectForKey:NSKeyValueChangeOldKey]; - NSNumber *new = [change objectForKey:NSKeyValueChangeNewKey]; - - if ([old isEqual:new]) - { - // No change in value - don't bother with any processing. - return; - } - - if ([keyPath isEqualToString:@"maximumNumberOfLogFiles"]) - { - NSLogInfo(@"DDFileLogManagerDefault: Responding to configuration change: maximumNumberOfLogFiles"); - - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - dispatch_block_t block = ^{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - [self deleteOldLogFiles]; - - [pool drain]; - }; - - dispatch_async([DDLog loggingQueue], block); - - #endif - } - else - { - #if GCD_MAYBE_UNAVAILABLE - - [self performSelector:@selector(deleteOldLogFiles) - onThread:[DDLog loggingThread] - withObject:nil - waitUntilDone:NO]; - - #endif - } - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark File Deleting -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -/** - * Deletes archived log files that exceed the maximumNumberOfLogFiles configuration value. -**/ -- (void)deleteOldLogFiles -{ - NSLogVerbose(@"DDLogFileManagerDefault: deleteOldLogFiles"); - - NSArray *sortedLogFileInfos = [self sortedLogFileInfos]; - - NSUInteger maxNumLogFiles = self.maximumNumberOfLogFiles; - - // Do we consider the first file? - // We are only supposed to be deleting archived files. - // In most cases, the first file is likely the log file that is currently being written to. - // So in most cases, we do not want to consider this file for deletion. - - NSUInteger count = [sortedLogFileInfos count]; - BOOL excludeFirstFile = NO; - - if (count > 0) - { - DDLogFileInfo *logFileInfo = [sortedLogFileInfos objectAtIndex:0]; - - if (!logFileInfo.isArchived) - { - excludeFirstFile = YES; - } - } - - NSArray *sortedArchivedLogFileInfos; - if (excludeFirstFile) - { - count--; - sortedArchivedLogFileInfos = [sortedLogFileInfos subarrayWithRange:NSMakeRange(1, count)]; - } - else - { - sortedArchivedLogFileInfos = sortedLogFileInfos; - } - - for (NSUInteger i = 0; i < count; i++) - { - if (i >= maxNumLogFiles) - { - DDLogFileInfo *logFileInfo = [sortedArchivedLogFileInfos objectAtIndex:i]; - - NSLogInfo(@"DDLogFileManagerDefault: Deleting file: %@", logFileInfo.fileName); - - [[NSFileManager defaultManager] removeItemAtPath:logFileInfo.filePath error:nil]; - } - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark Log Files -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -/** - * Returns the path to the logs directory. - * If the logs directory doesn't exist, this method automatically creates it. -**/ -- (NSString *)logsDirectory -{ -#if TARGET_OS_IPHONE - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); - NSString *baseDir = ([paths count] > 0) ? [paths objectAtIndex:0] : nil; -#else - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); - NSString *basePath = ([paths count] > 0) ? paths[0] : NSTemporaryDirectory(); - - NSString *appName = [[NSProcessInfo processInfo] processName]; - - NSString *baseDir = [basePath stringByAppendingPathComponent:appName]; -#endif - - NSString *logsDir = [baseDir stringByAppendingPathComponent:@"Logs"]; - - if(![[NSFileManager defaultManager] fileExistsAtPath:logsDir]) - { - NSError *err = nil; - if(![[NSFileManager defaultManager] createDirectoryAtPath:logsDir - withIntermediateDirectories:YES attributes:nil error:&err]) - { - NSLogError(@"DDFileLogManagerDefault: Error creating logsDirectory: %@", err); - } - } - - return logsDir; -} - -- (BOOL)isLogFile:(NSString *)fileName -{ - // A log file has a name like "log-.txt", where is a HEX-string of 6 characters. - // - // For example: log-DFFE99.txt - - BOOL hasProperPrefix = [fileName hasPrefix:@"log-"]; - - BOOL hasProperLength = [fileName length] >= 10; - - - if (hasProperPrefix && hasProperLength) - { - NSCharacterSet *hexSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789ABCDEF"]; - - NSString *hex = [fileName substringWithRange:NSMakeRange(4, 6)]; - NSString *nohex = [hex stringByTrimmingCharactersInSet:hexSet]; - - if ([nohex length] == 0) - { - return YES; - } - } - - return NO; -} - -/** - * Returns an array of NSString objects, - * each of which is the filePath to an existing log file on disk. -**/ -- (NSArray *)unsortedLogFilePaths -{ - NSString *logsDirectory = [self logsDirectory]; - - NSArray *fileNames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:logsDirectory error:nil]; - - NSMutableArray *unsortedLogFilePaths = [NSMutableArray arrayWithCapacity:[fileNames count]]; - - for (NSString *fileName in fileNames) - { - // Filter out any files that aren't log files. (Just for extra safety) - - if ([self isLogFile:fileName]) - { - NSString *filePath = [logsDirectory stringByAppendingPathComponent:fileName]; - - [unsortedLogFilePaths addObject:filePath]; - } - } - - return unsortedLogFilePaths; -} - -/** - * Returns an array of NSString objects, - * each of which is the fileName of an existing log file on disk. -**/ -- (NSArray *)unsortedLogFileNames -{ - NSArray *unsortedLogFilePaths = [self unsortedLogFilePaths]; - - NSMutableArray *unsortedLogFileNames = [NSMutableArray arrayWithCapacity:[unsortedLogFilePaths count]]; - - for (NSString *filePath in unsortedLogFilePaths) - { - [unsortedLogFileNames addObject:[filePath lastPathComponent]]; - } - - return unsortedLogFileNames; -} - -/** - * Returns an array of DDLogFileInfo objects, - * each representing an existing log file on disk, - * and containing important information about the log file such as it's modification date and size. -**/ -- (NSArray *)unsortedLogFileInfos -{ - NSArray *unsortedLogFilePaths = [self unsortedLogFilePaths]; - - NSMutableArray *unsortedLogFileInfos = [NSMutableArray arrayWithCapacity:[unsortedLogFilePaths count]]; - - for (NSString *filePath in unsortedLogFilePaths) - { - DDLogFileInfo *logFileInfo = [[DDLogFileInfo alloc] initWithFilePath:filePath]; - - [unsortedLogFileInfos addObject:logFileInfo]; - [logFileInfo release]; - } - - return unsortedLogFileInfos; -} - -/** - * Just like the unsortedLogFilePaths method, but sorts the array. - * The items in the array are sorted by modification date. - * The first item in the array will be the most recently modified log file. -**/ -- (NSArray *)sortedLogFilePaths -{ - NSArray *sortedLogFileInfos = [self sortedLogFileInfos]; - - NSMutableArray *sortedLogFilePaths = [NSMutableArray arrayWithCapacity:[sortedLogFileInfos count]]; - - for (DDLogFileInfo *logFileInfo in sortedLogFileInfos) - { - [sortedLogFilePaths addObject:[logFileInfo filePath]]; - } - - return sortedLogFilePaths; -} - -/** - * Just like the unsortedLogFileNames method, but sorts the array. - * The items in the array are sorted by modification date. - * The first item in the array will be the most recently modified log file. -**/ -- (NSArray *)sortedLogFileNames -{ - NSArray *sortedLogFileInfos = [self sortedLogFileInfos]; - - NSMutableArray *sortedLogFileNames = [NSMutableArray arrayWithCapacity:[sortedLogFileInfos count]]; - - for (DDLogFileInfo *logFileInfo in sortedLogFileInfos) - { - [sortedLogFileNames addObject:[logFileInfo fileName]]; - } - - return sortedLogFileNames; -} - -/** - * Just like the unsortedLogFileInfos method, but sorts the array. - * The items in the array are sorted by modification date. - * The first item in the array will be the most recently modified log file. -**/ -- (NSArray *)sortedLogFileInfos -{ - return [[self unsortedLogFileInfos] sortedArrayUsingSelector:@selector(reverseCompareByCreationDate:)]; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark Creation -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -/** - * Generates a short UUID suitable for use in the log file's name. - * The result will have six characters, all in the hexadecimal set [0123456789ABCDEF]. -**/ -- (NSString *)generateShortUUID -{ - CFUUIDRef uuid = CFUUIDCreate(NULL); - - CFStringRef fullStr = CFUUIDCreateString(NULL, uuid); - CFStringRef shortStr = CFStringCreateWithSubstring(NULL, fullStr, CFRangeMake(0, 6)); - - CFRelease(fullStr); - CFRelease(uuid); - - return [NSMakeCollectable(shortStr) autorelease]; -} - -/** - * Generates a new unique log file path, and creates the corresponding log file. -**/ -- (NSString *)createNewLogFile -{ - // Generate a random log file name, and create the file (if there isn't a collision) - - NSString *logsDirectory = [self logsDirectory]; - do - { - NSString *fileName = [NSString stringWithFormat:@"log-%@.txt", [self generateShortUUID]]; - - NSString *filePath = [logsDirectory stringByAppendingPathComponent:fileName]; - - if (![[NSFileManager defaultManager] fileExistsAtPath:filePath]) - { - NSLogVerbose(@"DDLogFileManagerDefault: Creating new log file: %@", fileName); - - [[NSFileManager defaultManager] createFileAtPath:filePath contents:nil attributes:nil]; - - // Since we just created a new log file, we may need to delete some old log files - [self deleteOldLogFiles]; - - return filePath; - } - - } while(YES); -} - -@end - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -@implementation DDLogFileFormatterDefault - -- (id)init -{ - if((self = [super init])) - { - dateFormatter = [[NSDateFormatter alloc] init]; - [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4]; - [dateFormatter setDateFormat:@"yyyy/MM/dd HH:mm:ss:SSS"]; - } - return self; -} - -- (NSString *)formatLogMessage:(DDLogMessage *)logMessage -{ - NSString *dateAndTime = [dateFormatter stringFromDate:(logMessage->timestamp)]; - - return [NSString stringWithFormat:@"%@ %@", dateAndTime, logMessage->logMsg]; -} - -- (void)dealloc -{ - [dateFormatter release]; - [super dealloc]; -} - -@end - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -@implementation DDFileLogger - -@synthesize maximumFileSize; -@synthesize rollingFrequency; -@synthesize logFileManager; - -- (id)init -{ - DDLogFileManagerDefault *defaultLogFileManager = [[[DDLogFileManagerDefault alloc] init] autorelease]; - - return [self initWithLogFileManager:defaultLogFileManager]; -} - -- (id)initWithLogFileManager:(id )aLogFileManager -{ - if ((self = [super init])) - { - maximumFileSize = DEFAULT_LOG_MAX_FILE_SIZE; - rollingFrequency = DEFAULT_LOG_ROLLING_FREQUENCY; - - logFileManager = [aLogFileManager retain]; - - formatter = [[DDLogFileFormatterDefault alloc] init]; - } - return self; -} - -- (void)dealloc -{ - [formatter release]; - [logFileManager release]; - - [currentLogFileInfo release]; - - [currentLogFileHandle synchronizeFile]; - [currentLogFileHandle closeFile]; - [currentLogFileHandle release]; - - [rollingTimer invalidate]; - [rollingTimer release]; - - [super dealloc]; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark Configuration -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -- (unsigned long long)maximumFileSize -{ - // The design of this method is taken from the DDAbstractLogger implementation. - // For documentation please refer to the DDAbstractLogger implementation. - - // Note: The internal implementation should access the maximumFileSize variable directly, - // but if we forget to do this, then this method should at least work properly. - - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - if (dispatch_get_current_queue() == loggerQueue) - { - return maximumFileSize; - } - - __block unsigned long long result; - - dispatch_block_t block = ^{ - result = maximumFileSize; - }; - dispatch_sync([DDLog loggingQueue], block); - - return result; - - #endif - } - else - { - #if GCD_MAYBE_UNAVAILABLE - - NSThread *loggingThread = [DDLog loggingThread]; - - if ([NSThread currentThread] == loggingThread) - { - return maximumFileSize; - } - - unsigned long long result; - NSMutableArray *resultHolder = [[NSMutableArray alloc] init]; - - [self performSelector:@selector(lt_getMaximumFileSize:) - onThread:loggingThread - withObject:resultHolder - waitUntilDone:YES]; - - OSMemoryBarrier(); - - result = [[resultHolder objectAtIndex:0] unsignedLongLongValue]; - [resultHolder release]; - - return result; - - #endif - } -} - -- (void)setMaximumFileSize:(unsigned long long)newMaximumFileSize -{ - // The design of this method is taken from the DDAbstractLogger implementation. - // For documentation please refer to the DDAbstractLogger implementation. - - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - dispatch_block_t block = ^{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - maximumFileSize = newMaximumFileSize; - [self maybeRollLogFileDueToSize]; - - [pool drain]; - }; - - if (dispatch_get_current_queue() == loggerQueue) - block(); - else - dispatch_async([DDLog loggingQueue], block); - - #endif - } - else - { - #if GCD_MAYBE_UNAVAILABLE - - NSThread *loggingThread = [DDLog loggingThread]; - NSNumber *newMaximumFileSizeWrapper = [NSNumber numberWithUnsignedLongLong:newMaximumFileSize]; - - if ([NSThread currentThread] == loggingThread) - { - [self lt_setMaximumFileSize:newMaximumFileSizeWrapper]; - } - else - { - [self performSelector:@selector(lt_setMaximumFileSize:) - onThread:loggingThread - withObject:newMaximumFileSizeWrapper - waitUntilDone:NO]; - } - - #endif - } -} - -- (NSTimeInterval)rollingFrequency -{ - // The design of this method is taken from the DDAbstractLogger implementation. - // For documentation please refer to the DDAbstractLogger implementation. - - // Note: The internal implementation should access the rollingFrequency variable directly, - // but if we forget to do this, then this method should at least work properly. - - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - if (dispatch_get_current_queue() == loggerQueue) - { - return rollingFrequency; - } - - __block NSTimeInterval result; - - dispatch_block_t block = ^{ - result = rollingFrequency; - }; - dispatch_sync([DDLog loggingQueue], block); - - return result; - - #endif - } - else - { - #if GCD_MAYBE_UNAVAILABLE - - NSThread *loggingThread = [DDLog loggingThread]; - - if ([NSThread currentThread] == loggingThread) - { - return rollingFrequency; - } - - NSTimeInterval result; - NSMutableArray *resultHolder = [[NSMutableArray alloc] init]; - - [self performSelector:@selector(lt_getRollingFrequency:) - onThread:loggingThread - withObject:resultHolder - waitUntilDone:YES]; - - OSMemoryBarrier(); - - result = [[resultHolder objectAtIndex:0] doubleValue]; - [resultHolder release]; - - return result; - - #endif - } -} - -- (void)setRollingFrequency:(NSTimeInterval)newRollingFrequency -{ - // The design of this method is taken from the DDAbstractLogger implementation. - // For documentation please refer to the DDAbstractLogger implementation. - - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - dispatch_block_t block = ^{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - rollingFrequency = newRollingFrequency; - [self maybeRollLogFileDueToAge:nil]; - - [pool drain]; - }; - - if (dispatch_get_current_queue() == loggerQueue) - block(); - else - dispatch_async([DDLog loggingQueue], block); - - #endif - } - else - { - #if GCD_MAYBE_UNAVAILABLE - - NSThread *loggingThread = [DDLog loggingThread]; - NSNumber *newMaximumRollingFrequencyWrapper = [NSNumber numberWithDouble:newRollingFrequency]; - - if ([NSThread currentThread] == loggingThread) - { - [self lt_setRollingFrequency:newMaximumRollingFrequencyWrapper]; - } - else - { - [self performSelector:@selector(lt_setRollingFrequency:) - onThread:loggingThread - withObject:newMaximumRollingFrequencyWrapper - waitUntilDone:NO]; - } - - #endif - } -} - -#if GCD_MAYBE_UNAVAILABLE - -- (void)lt_getMaximumFileSize:(NSMutableArray *)resultHolder -{ - // This method is executed on the logging thread. - - [resultHolder addObject:[NSNumber numberWithUnsignedLongLong:maximumFileSize]]; - OSMemoryBarrier(); -} - -- (void)lt_setMaximumFileSize:(NSNumber *)maximumFileSizeWrapper -{ - // This method is executed on the logging thread. - - maximumFileSize = [maximumFileSizeWrapper unsignedLongLongValue]; - - [self maybeRollLogFileDueToSize]; -} - -- (void)lt_getRollingFrequency:(NSMutableArray *)resultHolder -{ - // This method is executed on the logging thread. - - [resultHolder addObject:[NSNumber numberWithDouble:rollingFrequency]]; - OSMemoryBarrier(); -} - -- (void)lt_setRollingFrequency:(NSNumber *)rollingFrequencyWrapper -{ - // This method is executed on the logging thread. - - rollingFrequency = [rollingFrequencyWrapper doubleValue]; - - [self maybeRollLogFileDueToAge:nil]; -} - -#endif - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark File Rolling -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -- (void)scheduleTimerToRollLogFileDueToAge -{ - if (rollingTimer) - { - [rollingTimer invalidate]; - [rollingTimer release]; - rollingTimer = nil; - } - - if (currentLogFileInfo == nil) - { - return; - } - - NSDate *logFileCreationDate = [currentLogFileInfo creationDate]; - - NSTimeInterval ti = [logFileCreationDate timeIntervalSinceReferenceDate]; - ti += rollingFrequency; - - NSDate *logFileRollingDate = [NSDate dateWithTimeIntervalSinceReferenceDate:ti]; - - NSLogVerbose(@"DDFileLogger: scheduleTimerToRollLogFileDueToAge"); - - NSLogVerbose(@"DDFileLogger: logFileCreationDate: %@", logFileCreationDate); - NSLogVerbose(@"DDFileLogger: logFileRollingDate : %@", logFileRollingDate); - - rollingTimer = [[NSTimer scheduledTimerWithTimeInterval:[logFileRollingDate timeIntervalSinceNow] - target:self - selector:@selector(maybeRollLogFileDueToAge:) - userInfo:nil - repeats:NO] retain]; -} - -- (void)rollLogFile -{ - // This method is public. - // We need to execute the rolling on our logging thread/queue. - - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - dispatch_block_t block = ^{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [self rollLogFileNow]; - [pool drain]; - }; - dispatch_async([DDLog loggingQueue], block); - - #endif - } - else - { - #if GCD_MAYBE_UNAVAILABLE - - [self performSelector:@selector(rollLogFileNow) - onThread:[DDLog loggingThread] - withObject:nil - waitUntilDone:NO]; - - #endif - } -} - -- (void)rollLogFileNow -{ - NSLogVerbose(@"DDFileLogger: rollLogFileNow"); - - [currentLogFileHandle synchronizeFile]; - [currentLogFileHandle closeFile]; - [currentLogFileHandle release]; - currentLogFileHandle = nil; - - currentLogFileInfo.isArchived = YES; - - if ([logFileManager respondsToSelector:@selector(didRollAndArchiveLogFile:)]) - { - [logFileManager didRollAndArchiveLogFile:(currentLogFileInfo.filePath)]; - } - - [currentLogFileInfo release]; - currentLogFileInfo = nil; -} - -- (void)maybeRollLogFileDueToAge:(NSTimer *)aTimer -{ - if (currentLogFileInfo.age >= rollingFrequency) - { - NSLogVerbose(@"DDFileLogger: Rolling log file due to age..."); - - [self rollLogFileNow]; - } - else - { - [self scheduleTimerToRollLogFileDueToAge]; - } -} - -- (void)maybeRollLogFileDueToSize -{ - // This method is called from logMessage. - // Keep it FAST. - - unsigned long long fileSize = [currentLogFileHandle offsetInFile]; - - // Note: Use direct access to maximumFileSize variable. - // We specifically wrote our own getter/setter method to allow us to do this (for performance reasons). - - if (fileSize >= maximumFileSize) // YES, we are using direct access. Read note above. - { - NSLogVerbose(@"DDFileLogger: Rolling log file due to size..."); - - [self rollLogFileNow]; - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark File Logging -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -/** - * Returns the log file that should be used. - * If there is an existing log file that is suitable, - * within the constraints of maximumFileSize and rollingFrequency, then it is returned. - * - * Otherwise a new file is created and returned. -**/ -- (DDLogFileInfo *)currentLogFileInfo -{ - if (currentLogFileInfo == nil) - { - NSArray *sortedLogFileInfos = [logFileManager sortedLogFileInfos]; - - if ([sortedLogFileInfos count] > 0) - { - DDLogFileInfo *mostRecentLogFileInfo = sortedLogFileInfos[0]; - - BOOL useExistingLogFile = YES; - BOOL shouldArchiveMostRecent = NO; - - if (mostRecentLogFileInfo.isArchived) - { - useExistingLogFile = NO; - shouldArchiveMostRecent = NO; - } - else if (mostRecentLogFileInfo.fileSize >= maximumFileSize) - { - useExistingLogFile = NO; - shouldArchiveMostRecent = YES; - } - else if (mostRecentLogFileInfo.age >= rollingFrequency) - { - useExistingLogFile = NO; - shouldArchiveMostRecent = YES; - } - - if (useExistingLogFile) - { - NSLogVerbose(@"DDFileLogger: Resuming logging with file %@", mostRecentLogFileInfo.fileName); - - currentLogFileInfo = [mostRecentLogFileInfo retain]; - } - else - { - if (shouldArchiveMostRecent) - { - mostRecentLogFileInfo.isArchived = YES; - - if ([logFileManager respondsToSelector:@selector(didArchiveLogFile:)]) - { - [logFileManager didArchiveLogFile:(mostRecentLogFileInfo.filePath)]; - } - } - } - } - - if (currentLogFileInfo == nil) - { - NSString *currentLogFilePath = [logFileManager createNewLogFile]; - - currentLogFileInfo = [[DDLogFileInfo alloc] initWithFilePath:currentLogFilePath]; - } - } - - return currentLogFileInfo; -} - -- (NSFileHandle *)currentLogFileHandle -{ - if (currentLogFileHandle == nil) - { - NSString *logFilePath = [[self currentLogFileInfo] filePath]; - - currentLogFileHandle = [[NSFileHandle fileHandleForWritingAtPath:logFilePath] retain]; - [currentLogFileHandle seekToEndOfFile]; - - if (currentLogFileHandle) - { - [self scheduleTimerToRollLogFileDueToAge]; - } - } - - return currentLogFileHandle; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark DDLogger Protocol -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -- (void)logMessage:(DDLogMessage *)logMessage -{ - NSString *logMsg = logMessage->logMsg; - - if (formatter) - { - logMsg = [formatter formatLogMessage:logMessage]; - } - - if (logMsg) - { - if (![logMsg hasSuffix:@"\n"]) - { - logMsg = [logMsg stringByAppendingString:@"\n"]; - } - - NSData *logData = [logMsg dataUsingEncoding:NSUTF8StringEncoding]; - - [[self currentLogFileHandle] writeData:logData]; - - [self maybeRollLogFileDueToSize]; - } -} - -- (NSString *)loggerName -{ - return @"cocoa.lumberjack.fileLogger"; -} - -@end - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -#if TARGET_IPHONE_SIMULATOR - #define XATTR_ARCHIVED_NAME @"archived" -#else - #define XATTR_ARCHIVED_NAME @"lumberjack.log.archived" -#endif - -@implementation DDLogFileInfo - -@synthesize filePath; - -@dynamic fileName; -@dynamic fileAttributes; -@dynamic creationDate; -@dynamic modificationDate; -@dynamic fileSize; -@dynamic age; - -@dynamic isArchived; - - -#pragma mark Lifecycle - -+ (id)logFileWithPath:(NSString *)aFilePath -{ - return [[[DDLogFileInfo alloc] initWithFilePath:aFilePath] autorelease]; -} - -- (id)initWithFilePath:(NSString *)aFilePath -{ - if ((self = [super init])) - { - filePath = [aFilePath copy]; - } - return self; -} - -- (void)dealloc -{ - [filePath release]; - [fileName release]; - - [fileAttributes release]; - - [creationDate release]; - [modificationDate release]; - - [super dealloc]; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark Standard Info -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -- (NSDictionary *)fileAttributes -{ - if (fileAttributes == nil) - { - fileAttributes = [[[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil] retain]; - } - return fileAttributes; -} - -- (NSString *)fileName -{ - if (fileName == nil) - { - fileName = [[filePath lastPathComponent] retain]; - } - return fileName; -} - -- (NSDate *)modificationDate -{ - if (modificationDate == nil) - { - modificationDate = [[self fileAttributes][NSFileModificationDate] retain]; - } - - return modificationDate; -} - -- (NSDate *)creationDate -{ - if (creationDate == nil) - { - - #if TARGET_OS_IPHONE - - const char *path = [filePath UTF8String]; - - struct attrlist attrList; - memset(&attrList, 0, sizeof(attrList)); - attrList.bitmapcount = ATTR_BIT_MAP_COUNT; - attrList.commonattr = ATTR_CMN_CRTIME; - - struct { - u_int32_t attrBufferSizeInBytes; - struct timespec crtime; - } attrBuffer; - - int result = getattrlist(path, &attrList, &attrBuffer, sizeof(attrBuffer), 0); - if (result == 0) - { - double seconds = (double)(attrBuffer.crtime.tv_sec); - double nanos = (double)(attrBuffer.crtime.tv_nsec); - - NSTimeInterval ti = seconds + (nanos / 1000000000.0); - - creationDate = [[NSDate dateWithTimeIntervalSince1970:ti] retain]; - } - else - { - NSLogError(@"DDLogFileInfo: creationDate(%@): getattrlist result = %i", self.fileName, result); - } - - #else - - creationDate = [[self fileAttributes][NSFileCreationDate] retain]; - - #endif - - } - return creationDate; -} - -- (unsigned long long)fileSize -{ - if (fileSize == 0) - { - fileSize = [[self fileAttributes][NSFileSize] unsignedLongLongValue]; - } - - return fileSize; -} - -- (NSTimeInterval)age -{ - return [[self creationDate] timeIntervalSinceNow] * -1.0; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark Archiving -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -- (BOOL)isArchived -{ - -#if TARGET_IPHONE_SIMULATOR - - // Extended attributes don't work properly on the simulator. - // So we have to use a less attractive alternative. - // See full explanation in the header file. - - return [self hasExtensionAttributeWithName:XATTR_ARCHIVED_NAME]; - -#else - - return [self hasExtendedAttributeWithName:XATTR_ARCHIVED_NAME]; - -#endif -} - -- (void)setIsArchived:(BOOL)flag -{ - -#if TARGET_IPHONE_SIMULATOR - - // Extended attributes don't work properly on the simulator. - // So we have to use a less attractive alternative. - // See full explanation in the header file. - - if (flag) - [self addExtensionAttributeWithName:XATTR_ARCHIVED_NAME]; - else - [self removeExtensionAttributeWithName:XATTR_ARCHIVED_NAME]; - -#else - - if (flag) - [self addExtendedAttributeWithName:XATTR_ARCHIVED_NAME]; - else - [self removeExtendedAttributeWithName:XATTR_ARCHIVED_NAME]; - -#endif -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark Changes -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -- (void)reset -{ - [fileName release]; - fileName = nil; - - [fileAttributes release]; - fileAttributes = nil; - - [creationDate release]; - creationDate = nil; - - [modificationDate release]; - modificationDate = nil; -} - -- (void)renameFile:(NSString *)newFileName -{ - // This method is only used on the iPhone simulator, where normal extended attributes are broken. - // See full explanation in the header file. - - if (![newFileName isEqualToString:[self fileName]]) - { - NSString *fileDir = [filePath stringByDeletingLastPathComponent]; - - NSString *newFilePath = [fileDir stringByAppendingPathComponent:newFileName]; - - NSLogVerbose(@"DDLogFileInfo: Renaming file: '%@' -> '%@'", self.fileName, newFileName); - - NSError *error = nil; - if (![[NSFileManager defaultManager] moveItemAtPath:filePath toPath:newFilePath error:&error]) - { - NSLogError(@"DDLogFileInfo: Error renaming file (%@): %@", self.fileName, error); - } - - [filePath release]; - filePath = [newFilePath retain]; - - [self reset]; - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark Attribute Management -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -#if TARGET_IPHONE_SIMULATOR - -// Extended attributes don't work properly on the simulator. -// So we have to use a less attractive alternative. -// See full explanation in the header file. - -- (BOOL)hasExtensionAttributeWithName:(NSString *)attrName -{ - // This method is only used on the iPhone simulator, where normal extended attributes are broken. - // See full explanation in the header file. - - // Split the file name into components. - // - // log-ABC123.archived.uploaded.txt - // - // 0. log-ABC123 - // 1. archived - // 2. uploaded - // 3. txt - // - // So we want to search for the attrName in the components (ignoring the first and last array indexes). - - NSArray *components = [[self fileName] componentsSeparatedByString:@"."]; - - // Watch out for file names without an extension - - NSUInteger count = [components count]; - NSUInteger max = (count >= 2) ? count-1 : count; - - NSUInteger i; - for (i = 1; i < max; i++) - { - NSString *attr = [components objectAtIndex:i]; - - if ([attrName isEqualToString:attr]) - { - return YES; - } - } - - return NO; -} - -- (void)addExtensionAttributeWithName:(NSString *)attrName -{ - // This method is only used on the iPhone simulator, where normal extended attributes are broken. - // See full explanation in the header file. - - if ([attrName length] == 0) return; - - // Example: - // attrName = "archived" - // - // "log-ABC123.txt" -> "log-ABC123.archived.txt" - - NSArray *components = [[self fileName] componentsSeparatedByString:@"."]; - - NSUInteger count = [components count]; - - NSUInteger estimatedNewLength = [[self fileName] length] + [attrName length] + 1; - NSMutableString *newFileName = [NSMutableString stringWithCapacity:estimatedNewLength]; - - if (count > 0) - { - [newFileName appendString:[components objectAtIndex:0]]; - } - - NSString *lastExt = @""; - - NSUInteger i; - for (i = 1; i < count; i++) - { - NSString *attr = [components objectAtIndex:i]; - if ([attr length] == 0) - { - continue; - } - - if ([attrName isEqualToString:attr]) - { - // Extension attribute already exists in file name - return; - } - - if ([lastExt length] > 0) - { - [newFileName appendFormat:@".%@", lastExt]; - } - - lastExt = attr; - } - - [newFileName appendFormat:@".%@", attrName]; - - if ([lastExt length] > 0) - { - [newFileName appendFormat:@".%@", lastExt]; - } - - [self renameFile:newFileName]; -} - -- (void)removeExtensionAttributeWithName:(NSString *)attrName -{ - // This method is only used on the iPhone simulator, where normal extended attributes are broken. - // See full explanation in the header file. - - if ([attrName length] == 0) return; - - // Example: - // attrName = "archived" - // - // "log-ABC123.txt" -> "log-ABC123.archived.txt" - - NSArray *components = [[self fileName] componentsSeparatedByString:@"."]; - - NSUInteger count = [components count]; - - NSUInteger estimatedNewLength = [[self fileName] length]; - NSMutableString *newFileName = [NSMutableString stringWithCapacity:estimatedNewLength]; - - if (count > 0) - { - [newFileName appendString:[components objectAtIndex:0]]; - } - - BOOL found = NO; - - NSUInteger i; - for (i = 1; i < count; i++) - { - NSString *attr = [components objectAtIndex:i]; - - if ([attrName isEqualToString:attr]) - { - found = YES; - } - else - { - [newFileName appendFormat:@".%@", attr]; - } - } - - if (found) - { - [self renameFile:newFileName]; - } -} - -#else - -- (BOOL)hasExtendedAttributeWithName:(NSString *)attrName -{ - const char *path = [filePath UTF8String]; - const char *name = [attrName UTF8String]; - - int result = getxattr(path, name, NULL, 0, 0, 0); - - return (result >= 0); -} - -- (void)addExtendedAttributeWithName:(NSString *)attrName -{ - const char *path = [filePath UTF8String]; - const char *name = [attrName UTF8String]; - - int result = setxattr(path, name, NULL, 0, 0, 0); - - if (result < 0) - { - NSLogError(@"DDLogFileInfo: setxattr(%@, %@): error = %i", attrName, self.fileName, result); - } -} - -- (void)removeExtendedAttributeWithName:(NSString *)attrName -{ - const char *path = [filePath UTF8String]; - const char *name = [attrName UTF8String]; - - int result = removexattr(path, name, 0); - - if (result < 0 && errno != ENOATTR) - { - NSLogError(@"DDLogFileInfo: removexattr(%@, %@): error = %i", attrName, self.fileName, result); - } -} - -#endif - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark Comparisons -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -- (BOOL)isEqual:(id)object -{ - if ([object isKindOfClass:[self class]]) - { - DDLogFileInfo *another = (DDLogFileInfo *)object; - - return [filePath isEqualToString:[another filePath]]; - } - - return NO; -} - -- (NSComparisonResult)reverseCompareByCreationDate:(DDLogFileInfo *)another -{ - NSDate *us = [self creationDate]; - NSDate *them = [another creationDate]; - - NSComparisonResult result = [us compare:them]; - - if (result == NSOrderedAscending) - return NSOrderedDescending; - - if (result == NSOrderedDescending) - return NSOrderedAscending; - - return NSOrderedSame; -} - -- (NSComparisonResult)reverseCompareByModificationDate:(DDLogFileInfo *)another -{ - NSDate *us = [self modificationDate]; - NSDate *them = [another modificationDate]; - - NSComparisonResult result = [us compare:them]; - - if (result == NSOrderedAscending) - return NSOrderedDescending; - - if (result == NSOrderedDescending) - return NSOrderedAscending; - - return NSOrderedSame; -} - -@end diff --git a/Common/ThirdParty/CocoaLumberjack/DDLog.h b/Common/ThirdParty/CocoaLumberjack/DDLog.h deleted file mode 100755 index fb282485..00000000 --- a/Common/ThirdParty/CocoaLumberjack/DDLog.h +++ /dev/null @@ -1,529 +0,0 @@ -#import - -/** - * Welcome to Cocoa Lumberjack! - * - * The Google Code page has a wealth of documentation if you have any questions. - * http://code.google.com/p/cocoalumberjack/ - * - * If you're new to the project you may wish to read the "Getting Started" page. - * http://code.google.com/p/cocoalumberjack/wiki/GettingStarted - * - * Otherwise, here is a quick refresher. - * There are three steps to using the macros: - * - * Step 1: - * Import the header in your implementation file: - * - * #import "DDLog.h" - * - * Step 2: - * Define your logging level in your implementation file: - * - * // Debug levels: off, error, warn, info, verbose - * static const int ddLogLevel = LOG_LEVEL_VERBOSE; - * - * Step 3: - * Replace your NSLog statements with DDLog statements according to the severity of the message. - * - * NSLog(@"Fatal error, no dohickey found!"); -> DDLogError(@"Fatal error, no dohickey found!"); - * - * DDLog works exactly the same as NSLog. - * This means you can pass it multiple variables just like NSLog. -**/ - - -// Can we use Grand Central Dispatch? -// -// This question actually is actually composed of two parts: -// 1. Is it available to the compiler? -// 2. Is it available to the runtime? -// -// For example, if we are building a universal iPad/iPhone app, -// our base SDK may be iOS 4, but our deployment target would be iOS 3.2. -// In this case we can compile against the GCD libraries (which are available starting with iOS 4), -// but we can only use them at runtime if running on iOS 4 or later. -// If running on an iPad using iOS 3.2, we need to use runtime checks for backwards compatibility. -// -// The solution is to use a combination of compile-time and run-time macros. -// -// Note that when the minimum supported SDK supports GCD -// the run-time checks will be compiled out during optimization. - -#if TARGET_OS_IPHONE - - // Compiling for iPod/iPhone/iPad - - #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000 // 4.0 supported - - #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 40000 // 4.0 supported and required - - #define IS_GCD_AVAILABLE YES - #define GCD_MAYBE_AVAILABLE 1 - #define GCD_MAYBE_UNAVAILABLE 0 - - #else // 4.0 supported but not required - - #ifndef NSFoundationVersionNumber_iPhoneOS_4_0 - #define NSFoundationVersionNumber_iPhoneOS_4_0 751.32 - #endif - - #define IS_GCD_AVAILABLE (NSFoundationVersionNumber >= NSFoundationVersionNumber_iPhoneOS_4_0) - #define GCD_MAYBE_AVAILABLE 1 - #define GCD_MAYBE_UNAVAILABLE 1 - - #endif - - #else // 4.0 not supported - - #define IS_GCD_AVAILABLE NO - #define GCD_MAYBE_AVAILABLE 0 - #define GCD_MAYBE_UNAVAILABLE 1 - - #endif - -#else - - // Compiling for Mac OS X - - #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 // 10.6 supported - - #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 // 10.6 supported and required - - #define IS_GCD_AVAILABLE YES - #define GCD_MAYBE_AVAILABLE 1 - #define GCD_MAYBE_UNAVAILABLE 0 - - #else // 10.6 supported but not required - - #ifndef NSFoundationVersionNumber10_6 - #define NSFoundationVersionNumber10_6 751.00 - #endif - - #define IS_GCD_AVAILABLE (NSFoundationVersionNumber >= NSFoundationVersionNumber10_6) - #define GCD_MAYBE_AVAILABLE 1 - #define GCD_MAYBE_UNAVAILABLE 1 - - #endif - - #else // 10.6 not supported - - #define IS_GCD_AVAILABLE NO - #define GCD_MAYBE_AVAILABLE 0 - #define GCD_MAYBE_UNAVAILABLE 1 - - #endif - -#endif - -/* -// Uncomment for quick temporary test to see if it builds for older OS targets -#undef IS_GCD_AVAILABLE -#undef GCD_MAYBE_AVAILABLE -#undef GCD_MAYBE_UNAVAILABLE - -#define IS_GCD_AVAILABLE NO -#define GCD_MAYBE_AVAILABLE 0 -#define GCD_MAYBE_UNAVAILABLE 1 -*/ - -@class DDLogMessage; - -@protocol DDLogger; -@protocol DDLogFormatter; - -/** - * Define our big multiline macros so all the other macros will be easy to read. -**/ - -#define LOG_MACRO(isSynchronous, lvl, flg, fnct, frmt, ...) \ - [DDLog log:isSynchronous \ - level:lvl \ - flag:flg \ - file:__FILE__ \ - function:fnct \ - line:__LINE__ \ - format:(frmt), ##__VA_ARGS__] - -#define SYNC_LOG_OBJC_MACRO(lvl, flg, frmt, ...) LOG_MACRO(YES, lvl, flg, sel_getName(_cmd), frmt, ##__VA_ARGS__) -#define ASYNC_LOG_OBJC_MACRO(lvl, flg, frmt, ...) LOG_MACRO( NO, lvl, flg, sel_getName(_cmd), frmt, ##__VA_ARGS__) - -#define SYNC_LOG_C_MACRO(lvl, flg, frmt, ...) LOG_MACRO(YES, lvl, flg, __FUNCTION__, frmt, ##__VA_ARGS__) -#define ASYNC_LOG_C_MACRO(lvl, flg, frmt, ...) LOG_MACRO( NO, lvl, flg, __FUNCTION__, frmt, ##__VA_ARGS__) - -#define LOG_MAYBE(isSynchronous, lvl, flg, fnct, frmt, ...) \ - do { if(lvl & flg) LOG_MACRO(isSynchronous, lvl, flg, fnct, frmt, ##__VA_ARGS__); } while(0) - -#define SYNC_LOG_OBJC_MAYBE(lvl, flg, frmt, ...) LOG_MAYBE(YES, lvl, flg, sel_getName(_cmd), frmt, ##__VA_ARGS__) -#define ASYNC_LOG_OBJC_MAYBE(lvl, flg, frmt, ...) LOG_MAYBE( NO, lvl, flg, sel_getName(_cmd), frmt, ##__VA_ARGS__) - -#define SYNC_LOG_C_MAYBE(lvl, flg, frmt, ...) LOG_MAYBE(YES, lvl, flg, __FUNCTION__, frmt, ##__VA_ARGS__) -#define ASYNC_LOG_C_MAYBE(lvl, flg, frmt, ...) LOG_MAYBE( NO, lvl, flg, __FUNCTION__, frmt, ##__VA_ARGS__) - -/** - * Define our standard log levels. - * - * We default to only 4 levels because it makes it easier for beginners - * to make the transition to a logging framework. - * - * More advanced users may choose to completely customize the levels (and level names) to suite their needs. - * For more information on this see the "Custom Log Levels" page: - * http://code.google.com/p/cocoalumberjack/wiki/CustomLogLevels - * - * Advanced users may also notice that we're using a bitmask. - * This is to allow for custom fine grained logging: - * http://code.google.com/p/cocoalumberjack/wiki/FineGrainedLogging -**/ - -#define LOG_FLAG_ERROR (1 << 0) // 0...0001 -#define LOG_FLAG_WARN (1 << 1) // 0...0010 -#define LOG_FLAG_INFO (1 << 2) // 0...0100 -#define LOG_FLAG_VERBOSE (1 << 3) // 0...1000 - -#define LOG_LEVEL_OFF 0 -#define LOG_LEVEL_ERROR (LOG_FLAG_ERROR) // 0...0001 -#define LOG_LEVEL_WARN (LOG_FLAG_ERROR | LOG_FLAG_WARN) // 0...0011 -#define LOG_LEVEL_INFO (LOG_FLAG_ERROR | LOG_FLAG_WARN | LOG_FLAG_INFO) // 0...0111 -#define LOG_LEVEL_VERBOSE (LOG_FLAG_ERROR | LOG_FLAG_WARN | LOG_FLAG_INFO | LOG_FLAG_VERBOSE) // 0...1111 - -#define LOG_ERROR (ddLogLevel & LOG_FLAG_ERROR) -#define LOG_WARN (ddLogLevel & LOG_FLAG_WARN) -#define LOG_INFO (ddLogLevel & LOG_FLAG_INFO) -#define LOG_VERBOSE (ddLogLevel & LOG_FLAG_VERBOSE) - -#define DDLogError(frmt, ...) SYNC_LOG_OBJC_MAYBE(ddLogLevel, LOG_FLAG_ERROR, frmt, ##__VA_ARGS__) -#define DDLogWarn(frmt, ...) ASYNC_LOG_OBJC_MAYBE(ddLogLevel, LOG_FLAG_WARN, frmt, ##__VA_ARGS__) -#define DDLogInfo(frmt, ...) ASYNC_LOG_OBJC_MAYBE(ddLogLevel, LOG_FLAG_INFO, frmt, ##__VA_ARGS__) -#define DDLogVerbose(frmt, ...) ASYNC_LOG_OBJC_MAYBE(ddLogLevel, LOG_FLAG_VERBOSE, frmt, ##__VA_ARGS__) - -#define DDLogCError(frmt, ...) SYNC_LOG_C_MAYBE(ddLogLevel, LOG_FLAG_ERROR, frmt, ##__VA_ARGS__) -#define DDLogCWarn(frmt, ...) ASYNC_LOG_C_MAYBE(ddLogLevel, LOG_FLAG_WARN, frmt, ##__VA_ARGS__) -#define DDLogCInfo(frmt, ...) ASYNC_LOG_C_MAYBE(ddLogLevel, LOG_FLAG_INFO, frmt, ##__VA_ARGS__) -#define DDLogCVerbose(frmt, ...) ASYNC_LOG_C_MAYBE(ddLogLevel, LOG_FLAG_VERBOSE, frmt, ##__VA_ARGS__) - -/** - * The THIS_FILE macro gives you an NSString of the file name. - * For simplicity and clarity, the file name does not include the full path or file extension. - * - * For example: DDLogWarn(@"%@: Unable to find thingy", THIS_FILE) -> @"MyViewController: Unable to find thingy" -**/ - -NSString *ExtractFileNameWithoutExtension(const char *filePath, BOOL copy); - -#define THIS_FILE (ExtractFileNameWithoutExtension(__FILE__, NO)) - -/** - * The THIS_METHOD macro gives you the name of the current objective-c method. - * - * For example: DDLogWarn(@"%@ - Requires non-nil strings") -> @"setMake:model: requires non-nil strings" - * - * Note: This does NOT work in straight C functions (non objective-c). - * Instead you should use the predefined __FUNCTION__ macro. -**/ - -#define THIS_METHOD NSStringFromSelector(_cmd) - - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -@interface DDLog : NSObject - -#if GCD_MAYBE_AVAILABLE - -/** - * Provides access to the underlying logging queue. - * This may be helpful to Logger classes for things like thread synchronization. -**/ - -+ (dispatch_queue_t)loggingQueue; - -#endif - -#if GCD_MAYBE_UNAVAILABLE - -/** - * Provides access to the underlying logging thread. - * This may be helpful to Logger classes for things like thread synchronization. -**/ - -+ (NSThread *)loggingThread; - -#endif - -/** - * Logging Primitive. - * - * This method is used by the macros above. - * It is suggested you stick with the macros as they're easier to use. -**/ - -+ (void)log:(BOOL)synchronous - level:(int)level - flag:(int)flag - file:(const char *)file - function:(const char *)function - line:(int)line - format:(NSString *)format, ...; - -/** Sets the given filename and line to be stored to the next log message. - - This is used for nicer Xcode integration when issuing warnings and errors: we don't want Xcode pointing to appledoc files, but instead to user's source files that caused warnings/errors! After next log:level:flag:file:function:line:format: call, these values are reset. - */ -+ (void)storeFilename:(NSString *)file line:(NSUInteger)line; - -/** - * Since logging can be asynchronous, there may be times when you want to flush the logs. - * The framework invokes this automatically when the application quits. -**/ - -+ (void)flushLog; - -/** - * Loggers - * - * If you want your log statements to go somewhere, - * you should create and add a logger. -**/ - -+ (void)addLogger:(id )logger; -+ (void)removeLogger:(id )logger; - -+ (void)removeAllLoggers; - -/** - * Registered Dynamic Logging - * - * These methods allow you to obtain a list of classes that are using registered dynamic logging, - * and also provides methods to get and set their log level during run time. -**/ - -+ (NSArray *)registeredClasses; -+ (NSArray *)registeredClassNames; - -+ (int)logLevelForClass:(Class)aClass; -+ (int)logLevelForClassWithName:(NSString *)aClassName; - -+ (void)setLogLevel:(int)logLevel forClass:(Class)aClass; -+ (void)setLogLevel:(int)logLevel forClassWithName:(NSString *)aClassName; - -@end - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -@protocol DDLogger -@required - -- (void)logMessage:(DDLogMessage *)logMessage; - -/** - * Formatters may optionally be added to any logger. - * If no formatter is set, the logger simply logs the message as it is given in logMessage. - * Or it may use its own built in formatting style. -**/ -- (id )logFormatter; -- (void)setLogFormatter:(id )formatter; - -@optional - -/** - * Since logging is asynchronous, adding and removing loggers is also asynchronous. - * In other words, the loggers are added and removed at appropriate times with regards to log messages. - * - * - Loggers will not receive log messages that were executed prior to when they were added. - * - Loggers will not receive log messages that were executed after they were removed. - * - * These methods are executed in the logging thread/queue. - * This is the same thread/queue that will execute every logMessage: invocation. - * Loggers may use these methods for thread synchronization or other setup/teardown tasks. -**/ - -- (void)didAddLogger; -- (void)willRemoveLogger; - -#if GCD_MAYBE_AVAILABLE - -/** - * When Grand Central Dispatch is available - * each logger is executed concurrently with respect to the other loggers. - * Thus, a dedicated dispatch queue is used for each logger. - * Logger implementations may optionally choose to provide their own dispatch queue. -**/ -- (dispatch_queue_t)loggerQueue; - -/** - * If the logger implementation does not choose to provide its own queue, - * one will automatically be created for it. - * The created queue will receive its name from this method. - * This may be helpful for debugging or profiling reasons. -**/ -- (NSString *)loggerName; - -#endif - -@end - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -@protocol DDLogFormatter -@required - -/** - * Formatters may optionally be added to any logger. - * This allows for increased flexibility in the logging environment. - * For example, log messages for log files may be formatted differently than log messages for the console. - * - * For more information about formatters, see the "Custom Formatters" page: - * http://code.google.com/p/cocoalumberjack/wiki/CustomFormatters - * - * The formatter may also optionally filter the log message by returning nil, - * in which case the logger will not log the message. -**/ - -- (NSString *)formatLogMessage:(DDLogMessage *)logMessage; - -@end - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -@protocol DDRegisteredDynamicLogging - -/** - * Implement these methods to allow a file's log level to be managed from a central location. - * - * This is useful if you'd like to be able to change log levels for various parts - * of your code from within the running application. - * - * Imagine pulling up the settings for your application, - * and being able to configure the logging level on a per file basis. - * - * The implementation can be very straight-forward: - * - * + (int)ddLogLevel - * { - * return ddLogLevel; - * } - * - * + (void)ddSetLogLevel:(int)logLevel - * { - * ddLogLevel = logLevel; - * } -**/ - -+ (int)ddLogLevel; -+ (void)ddSetLogLevel:(int)logLevel; - -@end - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -/** - * The DDLogMessage class encapsulates information about the log message. - * If you write custom loggers or formatters, you will be dealing with objects of this class. -**/ - -@interface DDLogMessage : NSObject -{ - -// The public variables below can be accessed directly (for speed). -// For example: logMessage->logLevel - -@public - int logLevel; - int logFlag; - NSString *logMsg; - NSDate *timestamp; - const char *file; - const char *function; - int lineNumber; - mach_port_t machThreadID; - - NSString *originalFilename; - NSUInteger originalLine; - -// The private variables below are only calculated if needed. -// You should use the public methods to access this information. - -@private - NSString *threadID; - NSString *fileName; - NSString *methodName; -} - -// The initializer is somewhat reserved for internal use. -// However, if you find need to manually create logMessage objects, -// there is one thing you should be aware of. -// The initializer expects the file and function parameters to be string literals. -// That is, it expects the given strings to exist for the duration of the object's lifetime, -// and it expects the given strings to be immutable. -// In other words, it does not copy these strings, it simply points to them. - -- (id)initWithLogMsg:(NSString *)logMsg - level:(int)logLevel - flag:(int)logFlag - file:(const char *)file - function:(const char *)function - line:(int)line; - -/** - * Returns the threadID as it appears in NSLog. - * That is, it is a hexadecimal value which is calculated from the machThreadID. -**/ -- (NSString *)threadID; - -/** - * Convenience method to get just the file name, as the file variable is generally the full file path. - * This method does not include the file extension, which is generally unwanted for logging purposes. -**/ -- (NSString *)fileName; - -/** - * Returns the function variable in NSString form. -**/ -- (NSString *)methodName; - -@end - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -/** - * The DDLogger protocol specifies that an optional formatter can be added to a logger. - * Most (but not all) loggers will want to support formatters. - * - * However, writing getters and setters in a thread safe manner, - * while still maintaining maximum speed for the logging process, is a difficult task. - * - * To do it right, the implementation of the getter/setter has strict requiremenets: - * - Must NOT require the logMessage method to acquire a lock. - * - Must NOT require the logMessage method to access an atomic property (also a lock of sorts). - * - * To simplify things, an abstract logger is provided that implements the getter and setter. - * - * Logger implementations may simply extend this class, - * and they can ACCESS THE FORMATTER VARIABLE DIRECTLY from within their logMessage method! -**/ - -@interface DDAbstractLogger : NSObject -{ - id formatter; - -#if GCD_MAYBE_AVAILABLE - dispatch_queue_t loggerQueue; -#endif -} - -- (id )logFormatter; -- (void)setLogFormatter:(id )formatter; - -@end diff --git a/Common/ThirdParty/CocoaLumberjack/DDLog.m b/Common/ThirdParty/CocoaLumberjack/DDLog.m deleted file mode 100755 index f5db7fe4..00000000 --- a/Common/ThirdParty/CocoaLumberjack/DDLog.m +++ /dev/null @@ -1,1440 +0,0 @@ -#import "DDLog.h" - -#import -#import -#import -#import -#import - - -/** - * Welcome to Cocoa Lumberjack! - * - * The Google Code page has a wealth of documentation if you have any questions. - * http://code.google.com/p/cocoalumberjack/ - * - * If you're new to the project you may wish to read the "Getting Started" page. - * http://code.google.com/p/cocoalumberjack/wiki/GettingStarted - * -**/ - -// We probably shouldn't be using DDLog() statements within the DDLog implementation. -// But we still want to leave our log statements for any future debugging, -// and to allow other developers to trace the implementation (which is a great learning tool). -// -// So we use a primitive logging macro around NSLog. -// We maintain the NS prefix on the macros to be explicit about the fact that we're using NSLog. - -#define DDLOG_DEBUG NO - -#define NSLogDebug(frmt, ...) do{ if(DDLOG_DEBUG) NSLog((frmt), ##__VA_ARGS__); } while(0) - -// Specifies the maximum queue size of the logging thread. -// -// Since most logging is asynchronous, its possible for rogue threads to flood the logging queue. -// That is, to issue an abundance of log statements faster than the logging thread can keepup. -// Typically such a scenario occurs when log statements are added haphazardly within large loops, -// but may also be possible if relatively slow loggers are being used. -// -// This property caps the queue size at a given number of outstanding log statements. -// If a thread attempts to issue a log statement when the queue is already maxed out, -// the issuing thread will block until the queue size drops below the max again. - -#define LOG_MAX_QUEUE_SIZE 1000 // Should not exceed INT32_MAX - -#if GCD_MAYBE_AVAILABLE -struct LoggerNode { - id logger; - dispatch_queue_t loggerQueue; - struct LoggerNode * next; -}; -typedef struct LoggerNode LoggerNode; -#endif - - -@interface DDLog (PrivateAPI) - -+ (void)lt_addLogger:(id )logger; -+ (void)lt_removeLogger:(id )logger; -+ (void)lt_removeAllLoggers; -+ (void)lt_log:(DDLogMessage *)logMessage; -+ (void)lt_flush; - -@end - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -@implementation DDLog - -#if GCD_MAYBE_AVAILABLE - - // All logging statements are added to the same queue to ensure FIFO operation. - static dispatch_queue_t loggingQueue; - - // Individual loggers are executed concurrently per log statement. - // Each logger has it's own associated queue, and a dispatch group is used for synchrnoization. - static dispatch_group_t loggingGroup; - - // A linked list is used to manage all the individual loggers. - // Each item in the linked list also includes the loggers associated dispatch queue. - static LoggerNode *loggerNodes; - - // In order to prevent to queue from growing infinitely large, - // a maximum size is enforced (LOG_MAX_QUEUE_SIZE). - static dispatch_semaphore_t queueSemaphore; - - // Minor optimization for uniprocessor machines - static unsigned int numProcessors; - -#endif - -#if GCD_MAYBE_UNAVAILABLE - - // All logging statements are queued onto the same thread to ensure FIFO operation. - static NSThread *loggingThread; - - // An array is used to manage all the individual loggers. - // The array is only modified on the loggingThread. - static NSMutableArray *loggers; - - // In order to prevent to queue from growing infinitely large, - // a maximum size is enforced (LOG_MAX_QUEUE_SIZE). - static int32_t queueSize; // Incremented and decremented locklessly using OSAtomic operations - static NSCondition *condition; // Not used unless the queueSize exceeds its max - static NSMutableArray *blockedThreads; // Not used unless the queueSize exceeds its max - -#endif - -/** - * The runtime sends initialize to each class in a program exactly one time just before the class, - * or any class that inherits from it, is sent its first message from within the program. (Thus the - * method may never be invoked if the class is not used.) The runtime sends the initialize message to - * classes in a thread-safe manner. Superclasses receive this message before their subclasses. - * - * This method may also be called directly (assumably by accident), hence the safety mechanism. -**/ -+ (void)initialize -{ - static BOOL initialized = NO; - if (!initialized) - { - initialized = YES; - - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - NSLogDebug(@"DDLog: Using grand central dispatch"); - - loggingQueue = dispatch_queue_create("cocoa.lumberjack", NULL); - loggingGroup = dispatch_group_create(); - - loggerNodes = NULL; - - queueSemaphore = dispatch_semaphore_create(LOG_MAX_QUEUE_SIZE); - - // Figure out how many processors are available. - // This may be used later for an optimization on uniprocessor machines. - - host_basic_info_data_t hostInfo; - mach_msg_type_number_t infoCount; - - infoCount = HOST_BASIC_INFO_COUNT; - host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)&hostInfo, &infoCount); - - unsigned int result = (unsigned int)(hostInfo.max_cpus); - unsigned int one = (unsigned int)(1); - - numProcessors = MAX(result, one); - - NSLogDebug(@"DDLog: numProcessors = %u", numProcessors); - - #endif - } - else - { - #if GCD_MAYBE_UNAVAILABLE - - NSLogDebug(@"DDLog: GCD not available"); - - loggingThread = [[NSThread alloc] initWithTarget:self selector:@selector(lt_main:) object:nil]; - [loggingThread start]; - - loggers = [[NSMutableArray alloc] initWithCapacity:4]; - - queueSize = 0; - - condition = [[NSCondition alloc] init]; - blockedThreads = [[NSMutableArray alloc] init]; - - #endif - } - - #if TARGET_OS_IPHONE - NSString *notificationName = UIApplicationWillTerminateNotification; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(applicationWillTerminate:) - name:notificationName - object:nil]; - #endif - } -} - -#if GCD_MAYBE_AVAILABLE - -/** - * Provides access to the logging queue. -**/ -+ (dispatch_queue_t)loggingQueue -{ - return loggingQueue; -} - -#endif - -#if GCD_MAYBE_UNAVAILABLE - -/** - * Provides access to the logging thread. -**/ -+ (NSThread *)loggingThread -{ - return loggingThread; -} - -#endif - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark Notifications -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -+ (void)applicationWillTerminate:(NSNotification *)notification -{ - [self flushLog]; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark Logger Management -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -+ (void)addLogger:(id )logger -{ - if (logger == nil) return; - - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - dispatch_block_t addLoggerBlock = ^{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - [self lt_addLogger:logger]; - - [pool drain]; - }; - - dispatch_async(loggingQueue, addLoggerBlock); - - #endif - } - else - { - #if GCD_MAYBE_UNAVAILABLE - - [self performSelector:@selector(lt_addLogger:) onThread:loggingThread withObject:logger waitUntilDone:NO]; - - #endif - } -} - -+ (void)removeLogger:(id )logger -{ - if (logger == nil) return; - - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - dispatch_block_t removeLoggerBlock = ^{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - [self lt_removeLogger:logger]; - - [pool drain]; - }; - - dispatch_async(loggingQueue, removeLoggerBlock); - - #endif - } - else - { - #if GCD_MAYBE_UNAVAILABLE - - [self performSelector:@selector(lt_removeLogger:) onThread:loggingThread withObject:logger waitUntilDone:NO]; - - #endif - } -} - -+ (void)removeAllLoggers -{ - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - dispatch_block_t removeAllLoggersBlock = ^{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - [self lt_removeAllLoggers]; - - [pool drain]; - }; - - dispatch_async(loggingQueue, removeAllLoggersBlock); - - #endif - } - else - { - #if GCD_MAYBE_UNAVAILABLE - - [self performSelector:@selector(lt_removeAllLoggers) onThread:loggingThread withObject:nil waitUntilDone:NO]; - - #endif - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark Master Logging -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -+ (void)queueLogMessage:(DDLogMessage *)logMessage synchronously:(BOOL)flag -{ - // We have a tricky situation here... - // - // In the common case, when the queueSize is below the maximumQueueSize, - // we want to simply enqueue the logMessage. And we want to do this as fast as possible, - // which means we don't want to block and we don't want to use any locks. - // - // However, if the queueSize gets too big, we want to block. - // But we have very strict requirements as to when we block, and how long we block. - // - // The following example should help illustrate our requirements: - // - // Imagine that the maximum queue size is configured to be 5, - // and that there are already 5 log messages queued. - // Let us call these 5 queued log messages A, B, C, D, and E. (A is next to be executed) - // - // Now if our thread issues a log statement (let us call the log message F), - // it should block before the message is added to the queue. - // Furthermore, it should be unblocked immediately after A has been unqueued. - // - // The requirements are strict in this manner so that we block only as long as necessary, - // and so that blocked threads are unblocked in the order in which they were blocked. - // - // Returning to our previous example, let us assume that log messages A through E are still queued. - // Our aforementioned thread is blocked attempting to queue log message F. - // Now assume we have another separate thread that attempts to issue log message G. - // It should block until log messages A and B have been unqueued. - - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - // We are using a counting semaphore provided by GCD. - // The semaphore is initialized with our LOG_MAX_QUEUE_SIZE value. - // Everytime we want to queue a log message we decrement this value. - // If the resulting value is less than zero, - // the semaphore function waits in FIFO order for a signal to occur before returning. - // - // A dispatch semaphore is an efficient implementation of a traditional counting semaphore. - // Dispatch semaphores call down to the kernel only when the calling thread needs to be blocked. - // If the calling semaphore does not need to block, no kernel call is made. - - dispatch_semaphore_wait(queueSemaphore, DISPATCH_TIME_FOREVER); - - #endif - } - else - { - #if GCD_MAYBE_UNAVAILABLE - - // We're going increment our queue size (in an atomic fashion). - // If the queue size would exceed our LOG_MAX_QUEUE_SIZE value, - // then we're going to take a lock, and add ourself to the blocked threads array. - // Then we wait for the logging thread to signal us. - // When it does, we automatically reaquire the lock, - // and check to see if we have been removed from the blocked threads array. - // When this occurs we are unblocked, and we can go ahead and queue our log message. - - int32_t newQueueSize = OSAtomicIncrement32(&queueSize); - if (newQueueSize > LOG_MAX_QUEUE_SIZE) - { - NSLogDebug(@"DDLog: Blocking thread %@ (newQueueSize=%i)", [logMessage threadID], newQueueSize); - - [condition lock]; - - NSString *currentThreadID = [logMessage threadID]; - [blockedThreads addObject:currentThreadID]; - - NSUInteger lastKnownIndex = [blockedThreads count] - 1; - - if (lastKnownIndex == 0) - { - NSLogDebug(@"DDLog: Potential edge case: First blocked thread -> Signaling condition..."); - - // Edge case: - // The loggingThread/loggingQueue acquired the lock before we did, - // but it immediately discovered the blockedThreads array was empty. - - [condition signal]; - } - - BOOL done = NO; - while (!done) - { - BOOL found = NO; - NSUInteger i; - NSUInteger count = [blockedThreads count]; - - for (i = 0; i <= lastKnownIndex && i < count && !found; i++) - { - NSString *blockedThreadID = [blockedThreads objectAtIndex:i]; - - // Instead of doing a string comparison, - // we can save CPU cycles by doing an pointer comparison, - // since we still have access to the string that we added the array. - - if (blockedThreadID == currentThreadID) - { - found = YES; - lastKnownIndex = i; - } - } - - // If our currentThreadID is still in the blockedThreads array, - // then we are still blocked, and we're not done. - - done = !found; - - if (!done) - { - [condition wait]; - } - } - - - [condition unlock]; - - NSLogDebug(@"DDLog: Unblocking thread %@", [logMessage threadID]); - } - - #endif - } - - // We've now sure we won't overflow the queue. - // It is time to queue our log message. - - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - dispatch_block_t logBlock = ^{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - [self lt_log:logMessage]; - - [pool drain]; - }; - - if (flag) - dispatch_sync(loggingQueue, logBlock); - else - dispatch_async(loggingQueue, logBlock); - - #endif - } - else - { - #if GCD_MAYBE_UNAVAILABLE - - [self performSelector:@selector(lt_log:) onThread:loggingThread withObject:logMessage waitUntilDone:flag]; - - #endif - } -} - -static NSString *GBStoreFilename = nil; -static NSUInteger GBStoreLine = 0; -+ (void)storeFilename:(NSString *)file line:(NSUInteger)line { - GBStoreFilename = [file retain]; - GBStoreLine = line; -} - -+ (void)log:(BOOL)synchronous - level:(int)level - flag:(int)flag - file:(const char *)file - function:(const char *)function - line:(int)line - format:(NSString *)format, ... -{ - va_list args; - if (format) - { - va_start(args, format); - - NSString *logMsg = [[NSString alloc] initWithFormat:format arguments:args]; - DDLogMessage *logMessage = [[DDLogMessage alloc] initWithLogMsg:logMsg - level:level - flag:flag - file:file - function:function - line:line]; - - if (GBStoreFilename) { - logMessage->originalFilename = GBStoreFilename; - logMessage->originalLine = GBStoreLine; - GBStoreFilename = nil; - } - - [self queueLogMessage:logMessage synchronously:synchronous]; - - [logMessage release]; - [logMsg release]; - - va_end(args); - } -} - -+ (void)flushLog -{ - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - dispatch_block_t flushBlock = ^{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - [self lt_flush]; - - [pool drain]; - }; - - dispatch_sync(loggingQueue, flushBlock); - - #endif - } - else - { - #if GCD_MAYBE_UNAVAILABLE - - [self performSelector:@selector(lt_flush) onThread:loggingThread withObject:nil waitUntilDone:YES]; - - #endif - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark Registered Dynamic Logging -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -+ (BOOL)isRegisteredClass:(Class)class -{ - SEL getterSel = @selector(ddLogLevel); - SEL setterSel = @selector(ddSetLogLevel:); - - Method getter = class_getClassMethod(class, getterSel); - Method setter = class_getClassMethod(class, setterSel); - - return (getter != NULL) && (setter != NULL); - -} - -+ (NSArray *)registeredClasses -{ - int numClasses; - - // We're going to get the list of all registered classes. - // The Objective-C runtime library automatically registers all the classes defined in your source code. - // - // To do this we use the following method (documented in the Objective-C Runtime Reference): - // - // int objc_getClassList(Class *buffer, int bufferLen) - // - // We can pass (NULL, 0) to obtain the total number of - // registered class definitions without actually retrieving any class definitions. - // This allows us to allocate the minimum amount of memory needed for the application. - - numClasses = objc_getClassList(NULL, 0); - - // The numClasses method now tells us how many classes we have. - // So we can allocate our buffer, and get pointers to all the class definitions. - - Class *classes = (Class*)malloc(sizeof(Class) * numClasses); - - numClasses = objc_getClassList(classes, numClasses); - - // We can now loop through the classes, and test each one to see if it is a DDLogging class. - - NSMutableArray *result = [NSMutableArray arrayWithCapacity:numClasses]; - - for (int i = 0; i < numClasses; i++) - { - Class class = classes[i]; - - if ([self isRegisteredClass:class]) - { - [result addObject:class]; - } - } - - free(classes); - - return result; -} - -+ (NSArray *)registeredClassNames -{ - NSArray *registeredClasses = [self registeredClasses]; - NSMutableArray *result = [NSMutableArray arrayWithCapacity:[registeredClasses count]]; - - for (Class class in registeredClasses) - { - [result addObject:NSStringFromClass(class)]; - } - - return result; -} - -+ (int)logLevelForClass:(Class)aClass -{ - if ([self isRegisteredClass:aClass]) - { - return [aClass ddLogLevel]; - } - - return -1; -} - -+ (int)logLevelForClassWithName:(NSString *)aClassName -{ - Class aClass = NSClassFromString(aClassName); - - return [self logLevelForClass:aClass]; -} - -+ (void)setLogLevel:(int)logLevel forClass:(Class)aClass -{ - if ([self isRegisteredClass:aClass]) - { - [aClass ddSetLogLevel:logLevel]; - } -} - -+ (void)setLogLevel:(int)logLevel forClassWithName:(NSString *)aClassName -{ - Class aClass = NSClassFromString(aClassName); - - [self setLogLevel:logLevel forClass:aClass]; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark Logging Thread -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -#if GCD_MAYBE_UNAVAILABLE - -/** - * Entry point for logging thread. -**/ -+ (void)lt_main:(id)ignore -{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - // We can't run the run loop unless it has an associated input source or a timer. - // So we'll just create a timer that will never fire - unless the server runs for 10,000 years. - [NSTimer scheduledTimerWithTimeInterval:DBL_MAX target:self selector:@selector(ignore:) userInfo:nil repeats:NO]; - - [[NSRunLoop currentRunLoop] run]; - - [pool release]; -} - -#endif - -/** - * This method should only be run on the logging thread/queue. -**/ -+ (void)lt_addLogger:(id )logger -{ - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - // Add to linked list of LoggerNode elements. - // Need to create loggerQueue if loggerNode doesn't provide one. - - LoggerNode *loggerNode = malloc(sizeof(LoggerNode)); - loggerNode->logger = [logger retain]; - - if ([logger respondsToSelector:@selector(loggerQueue)]) - { - // Logger is providing its own queue - - loggerNode->loggerQueue = [logger loggerQueue]; - dispatch_retain(loggerNode->loggerQueue); - } - else - { - // Automatically create queue for the logger. - // Use the logger name as the queue name if possible. - - const char *loggerQueueName = NULL; - if ([logger respondsToSelector:@selector(loggerName)]) - { - loggerQueueName = [[logger loggerName] UTF8String]; - } - - loggerNode->loggerQueue = dispatch_queue_create(loggerQueueName, NULL); - } - - loggerNode->next = loggerNodes; - loggerNodes = loggerNode; - - #endif - } - else - { - #if GCD_MAYBE_UNAVAILABLE - - // Add to loggers array - - [loggers addObject:logger]; - - #endif - } - - if ([logger respondsToSelector:@selector(didAddLogger)]) - { - [logger didAddLogger]; - } -} - -/** - * This method should only be run on the logging thread/queue. -**/ -+ (void)lt_removeLogger:(id )logger -{ - if ([logger respondsToSelector:@selector(willRemoveLogger)]) - { - [logger willRemoveLogger]; - } - - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - // Remove from linked list of LoggerNode elements. - // - // Need to release: - // - logger - // - loggerQueue - // - loggerNode - - LoggerNode *prevNode = NULL; - LoggerNode *currentNode = loggerNodes; - - while (currentNode) - { - if (currentNode->logger == logger) - { - if (prevNode) - { - // LoggerNode had previous node pointing to it. - prevNode->next = currentNode->next; - } - else - { - // LoggerNode was first in list. Update loggerNodes pointer. - loggerNodes = currentNode->next; - } - - [currentNode->logger release]; - currentNode->logger = nil; - - dispatch_release(currentNode->loggerQueue); - currentNode->loggerQueue = NULL; - - currentNode->next = NULL; - - free(currentNode); - - break; - } - - prevNode = currentNode; - currentNode = currentNode->next; - } - - #endif - } - else - { - #if GCD_MAYBE_UNAVAILABLE - - // Remove from loggers array - - [loggers removeObject:logger]; - - #endif - } -} - -/** - * This method should only be run on the logging thread/queue. -**/ -+ (void)lt_removeAllLoggers -{ - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - // Iterate through linked list of LoggerNode elements. - // For each one, notify the logger, and deallocate all associated resources. - // - // Need to release: - // - logger - // - loggerQueue - // - loggerNode - - LoggerNode *nextNode; - LoggerNode *currentNode = loggerNodes; - - while (currentNode) - { - if ([currentNode->logger respondsToSelector:@selector(willRemoveLogger)]) - { - [currentNode->logger willRemoveLogger]; - } - - nextNode = currentNode->next; - - [currentNode->logger release]; - currentNode->logger = nil; - - dispatch_release(currentNode->loggerQueue); - currentNode->loggerQueue = NULL; - - currentNode->next = NULL; - - free(currentNode); - - currentNode = nextNode; - } - - loggerNodes = NULL; - - #endif - } - else - { - #if GCD_MAYBE_UNAVAILABLE - - // Notify all loggers. - // And then remove them all from loggers array. - - for (id logger in loggers) - { - if ([logger respondsToSelector:@selector(willRemoveLogger)]) - { - [logger willRemoveLogger]; - } - } - - [loggers removeAllObjects]; - - #endif - } -} - -/** - * This method should only be run on the logging thread/queue. -**/ -+ (void)lt_log:(DDLogMessage *)logMessage -{ - // Execute the given log message on each of our loggers. - - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - if (numProcessors > 1) - { - // Execute each logger concurrently, each within its own queue. - // All blocks are added to same group. - // After each block has been queued, wait on group. - // - // The waiting ensures that a slow logger doesn't end up with a large queue of pending log messages. - // This would defeat the purpose of the efforts we made earlier to restrict the max queue size. - - LoggerNode *currentNode = loggerNodes; - - while (currentNode) - { - dispatch_block_t loggerBlock = ^{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - [currentNode->logger logMessage:logMessage]; - - [pool drain]; - }; - - dispatch_group_async(loggingGroup, currentNode->loggerQueue, loggerBlock); - - currentNode = currentNode->next; - } - - dispatch_group_wait(loggingGroup, DISPATCH_TIME_FOREVER); - } - else - { - // Execute each logger serialy, each within its own queue. - - LoggerNode *currentNode = loggerNodes; - - while (currentNode) - { - dispatch_block_t loggerBlock = ^{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - [currentNode->logger logMessage:logMessage]; - - [pool drain]; - }; - - dispatch_sync(currentNode->loggerQueue, loggerBlock); - - currentNode = currentNode->next; - } - } - - #endif - } - else - { - #if GCD_MAYBE_UNAVAILABLE - - for (id logger in loggers) - { - [logger logMessage:logMessage]; - } - - #endif - } - - // If our queue got too big, there may be blocked threads waiting to add log messages to the queue. - // Since we've now dequeued an item from the log, we may need to unblock the next thread. - - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - // We are using a counting semaphore provided by GCD. - // The semaphore is initialized with our LOG_MAX_QUEUE_SIZE value. - // When a log message is queued this value is decremented. - // When a log message is dequeued this value is incremented. - // If the value ever drops below zero, - // the queueing thread blocks and waits in FIFO order for us to signal it. - // - // A dispatch semaphore is an efficient implementation of a traditional counting semaphore. - // Dispatch semaphores call down to the kernel only when the calling thread needs to be blocked. - // If the calling semaphore does not need to block, no kernel call is made. - - dispatch_semaphore_signal(queueSemaphore); - - #endif - } - else - { - #if GCD_MAYBE_UNAVAILABLE - - int32_t newQueueSize = OSAtomicDecrement32(&queueSize); - if (newQueueSize >= LOG_MAX_QUEUE_SIZE) - { - // There is an existing blocked thread waiting for us. - // When the thread went to queue a log message, it first incremented the queueSize. - // At this point it realized that was going to exceed the maxQueueSize. - // It then added itself to the blockedThreads list, and is now waiting for us to signal it. - - [condition lock]; - - while ([blockedThreads count] == 0) - { - NSLogDebug(@"DDLog: Edge case: Empty blocked threads array -> Waiting for condition..."); - - // Edge case. - // We acquired the lock before the blockedThread did. - // That is why the array is empty. - // Allow it to acquire the lock and signal us. - - [condition wait]; - } - - // The blockedThreads variable is acting as a queue. (FIFO) - // Whatever was the first thread to block can now be unblocked. - // This means that thread will block only until the count of - // prevoiusly queued plus previously reserved log messages before it have dropped below the maxQueueSize. - - NSLogDebug(@"DDLog: Signaling thread %@ (newQueueSize=%i)", [blockedThreads objectAtIndex:0], newQueueSize); - - [blockedThreads removeObjectAtIndex:0]; - [condition broadcast]; - - [condition unlock]; - } - - #endif - } -} - -/** - * This method should only be run on the background logging thread. -**/ -+ (void)lt_flush -{ - // All log statements issued before the flush method was invoked have now been flushed -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark Utilities -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -NSString *ExtractFileNameWithoutExtension(const char *filePath, BOOL copy) -{ - if (filePath == NULL) return nil; - - char *lastSlash = NULL; - char *lastDot = NULL; - - char *p = (char *)filePath; - - while (*p != '\0') - { - if (*p == '/') - lastSlash = p; - else if (*p == '.') - lastDot = p; - - p++; - } - - char *subStr; - NSUInteger subLen; - - if (lastSlash) - { - if (lastDot) - { - // lastSlash -> lastDot - subStr = lastSlash + 1; - subLen = lastDot - subStr; - } - else - { - // lastSlash -> endOfString - subStr = lastSlash + 1; - subLen = p - subStr; - } - } - else - { - if (lastDot) - { - // startOfString -> lastDot - subStr = (char *)filePath; - subLen = lastDot - subStr; - } - else - { - // startOfString -> endOfString - subStr = (char *)filePath; - subLen = p - subStr; - } - } - - if (copy) - { - return [[[NSString alloc] initWithBytes:subStr - length:subLen - encoding:NSUTF8StringEncoding] autorelease]; - } - else - { - // We can take advantage of the fact that __FILE__ is a string literal. - // Specifically, we don't need to waste time copying the string. - // We can just tell NSString to point to a range within the string literal. - - return [[[NSString alloc] initWithBytesNoCopy:subStr - length:subLen - encoding:NSUTF8StringEncoding - freeWhenDone:NO] autorelease]; - } -} - -@end - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -@implementation DDLogMessage - -- (id)initWithLogMsg:(NSString *)msg - level:(int)level - flag:(int)flag - file:(const char *)aFile - function:(const char *)aFunction - line:(int)line -{ - if((self = [super init])) - { - logMsg = [msg retain]; - logLevel = level; - logFlag = flag; - file = aFile; - function = aFunction; - lineNumber = line; - - timestamp = [[NSDate alloc] init]; - - machThreadID = pthread_mach_thread_np(pthread_self()); - } - return self; -} - -- (NSString *)threadID -{ - if (threadID == nil) - { - threadID = [[NSString alloc] initWithFormat:@"%x", machThreadID]; - } - - return threadID; -} - -- (NSString *)fileName -{ - if (fileName == nil) - { - fileName = [ExtractFileNameWithoutExtension(file, NO) retain]; - } - - return fileName; -} - -- (NSString *)methodName -{ - if (methodName == nil && function != NULL) - { - methodName = [[NSString alloc] initWithUTF8String:function]; - } - - return methodName; -} - -- (void)dealloc -{ - [logMsg release]; - [timestamp release]; - - [threadID release]; - [methodName release]; - - [super dealloc]; -} - -@end - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -@implementation DDAbstractLogger - -- (id)init -{ - if ((self = [super init])) - { - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - const char *loggerQueueName = NULL; - if ([self respondsToSelector:@selector(loggerName)]) - { - loggerQueueName = [[self loggerName] UTF8String]; - } - - loggerQueue = dispatch_queue_create(loggerQueueName, NULL); - - #endif - } - } - return self; -} - -- (void)dealloc -{ - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - dispatch_release(loggerQueue); - #endif - } - - [super dealloc]; -} - -- (void)logMessage:(DDLogMessage *)logMessage -{ - // Override me -} - -#if GCD_MAYBE_UNAVAILABLE - -- (void)lt_getLogFormatter:(NSMutableArray *)resultHolder -{ - // This method is executed on the logging thread. - - [resultHolder addObject:formatter]; - OSMemoryBarrier(); -} - -- (void)lt_setLogFormatter:(id )logFormatter -{ - // This method is executed on the logging thread. - - if (formatter != logFormatter) - { - [formatter release]; - formatter = [logFormatter retain]; - } -} - -#endif - -- (id )logFormatter -{ - // This method must be thread safe and intuitive. - // Therefore if somebody executes the following code: - // - // [logger setLogFormatter:myFormatter]; - // formatter = [logger logFormatter]; - // - // They would expect formatter to equal myFormatter. - // This functionality must be ensured by the getter and setter method. - // - // The thread safety must not come at a cost to the performance of the logMessage method. - // This method is likely called sporadically, while the logMessage method is called repeatedly. - // This means, the implementation of this method: - // - Must NOT require the logMessage method to acquire a lock. - // - Must NOT require the logMessage method to access an atomic property (also a lock of sorts). - // - // Thread safety is ensured by executing access to the formatter variable on the logging thread/queue. - // This is the same thread/queue that the logMessage method operates on. - // - // Note: The last time I benchmarked the performance of direct access vs atomic property access, - // direct access was over twice as fast on the desktop and over 6 times as fast on the iPhone. - - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - // loggerQueue : Our own private internal queue that the logMessage method runs on. - // Operations are added to this queue from the global loggingQueue. - // - // loggingQueue : The queue that all log messages go through before they arrive in our loggerQueue. - // - // It is important to note that, while the loggerQueue is used to create thread-safety for our formatter, - // changes to the formatter variable are queued on the loggingQueue. - // - // Since this will obviously confuse the hell out of me later, here is a better description. - // Imagine the following code: - // - // DDLogVerbose(@"log msg 1"); - // DDLogVerbose(@"log msg 2"); - // [logger setFormatter:myFormatter]; - // DDLogVerbose(@"log msg 3"); - // - // Our intuitive requirement means that the new formatter will only apply to the 3rd log message. - // But notice what happens if we have asynchronous logging enabled for verbose mode. - // - // Log msg 1 starts executing asynchronously on the loggingQueue. - // The loggingQueue executes the log statement on each logger concurrently. - // That means it executes log msg 1 on our loggerQueue. - // While log msg 1 is executing, log msg 2 gets added to the loggingQueue. - // Then the user requests that we change our formatter. - // So at this exact moment, our queues look like this: - // - // loggerQueue : executing log msg 1, nil - // loggingQueue : executing log msg 1, log msg 2, nil - // - // So direct access to the formatter is only available if requested from the loggerQueue. - // In all other circumstances we need to go through the loggingQueue to get the proper value. - - if (dispatch_get_current_queue() == loggerQueue) - { - return formatter; - } - - __block id result; - - dispatch_block_t block = ^{ - result = [formatter retain]; - }; - dispatch_sync([DDLog loggingQueue], block); - - return [result autorelease]; - - #endif - } - else - { - #if GCD_MAYBE_UNAVAILABLE - - NSThread *loggingThread = [DDLog loggingThread]; - - if ([NSThread currentThread] == loggingThread) - { - return formatter; - } - - NSMutableArray *resultHolder = [[NSMutableArray alloc] init]; - - [self performSelector:@selector(lt_getLogFormatter:) - onThread:loggingThread - withObject:resultHolder - waitUntilDone:YES]; - - OSMemoryBarrier(); - - id result = [[resultHolder objectAtIndex:0] retain]; - [resultHolder release]; - - return [result autorelease]; - - #endif - } -} - -- (void)setLogFormatter:(id )logFormatter -{ - // This method must be thread safe and intuitive. - // Therefore if somebody executes the following code: - // - // [logger setLogFormatter:myFormatter]; - // formatter = [logger logFormatter]; - // - // They would expect formatter to equal myFormatter. - // This functionality must be ensured by the getter and setter method. - // - // The thread safety must not come at a cost to the performance of the logMessage method. - // This method is likely called sporadically, while the logMessage method is called repeatedly. - // This means, the implementation of this method: - // - Must NOT require the logMessage method to acquire a lock. - // - Must NOT require the logMessage method to access an atomic property (also a lock of sorts). - // - // Thread safety is ensured by executing access to the formatter variable on the logging thread/queue. - // This is the same thread/queue that the logMessage method operates on. - // - // Note: The last time I benchmarked the performance of direct access vs atomic property access, - // direct access was over twice as fast on the desktop and over 6 times as fast on the iPhone. - - if (IS_GCD_AVAILABLE) - { - #if GCD_MAYBE_AVAILABLE - - // loggerQueue : Our own private internal queue that the logMessage method runs on. - // Operations are added to this queue from the global loggingQueue. - // - // loggingQueue : The queue that all log messages go through before they arrive in our loggerQueue. - // - // It is important to note that, while the loggerQueue is used to create thread-safety for our formatter, - // changes to the formatter variable are queued on the loggingQueue. - // - // Since this will obviously confuse the hell out of me later, here is a better description. - // Imagine the following code: - // - // DDLogVerbose(@"log msg 1"); - // DDLogVerbose(@"log msg 2"); - // [logger setFormatter:myFormatter]; - // DDLogVerbose(@"log msg 3"); - // - // Our intuitive requirement means that the new formatter will only apply to the 3rd log message. - // But notice what happens if we have asynchronous logging enabled for verbose mode. - // - // Log msg 1 starts executing asynchronously on the loggingQueue. - // The loggingQueue executes the log statement on each logger concurrently. - // That means it executes log msg 1 on our loggerQueue. - // While log msg 1 is executing, log msg 2 gets added to the loggingQueue. - // Then the user requests that we change our formatter. - // So at this exact moment, our queues look like this: - // - // loggerQueue : executing log msg 1, nil - // loggingQueue : executing log msg 1, log msg 2, nil - // - // So direct access to the formatter is only available if requested from the loggerQueue. - // In all other circumstances we need to go through the loggingQueue to get the proper value. - - dispatch_block_t block = ^{ - if (formatter != logFormatter) - { - [formatter release]; - formatter = [logFormatter retain]; - } - }; - - if (dispatch_get_current_queue() == loggerQueue) - block(); - else - dispatch_async([DDLog loggingQueue], block); - - #endif - } - else - { - #if GCD_MAYBE_UNAVAILABLE - - NSThread *loggingThread = [DDLog loggingThread]; - - if ([NSThread currentThread] == loggingThread) - { - [self lt_setLogFormatter:logFormatter]; - } - else - { - [self performSelector:@selector(lt_setLogFormatter:) - onThread:loggingThread - withObject:logFormatter - waitUntilDone:NO]; - } - - #endif - } -} - -#if GCD_MAYBE_AVAILABLE - -- (dispatch_queue_t)loggerQueue -{ - return loggerQueue; -} - -#endif - -@end diff --git a/Common/ThirdParty/CocoaLumberjack/DDTTYLogger.h b/Common/ThirdParty/CocoaLumberjack/DDTTYLogger.h deleted file mode 100755 index 70ce46ad..00000000 --- a/Common/ThirdParty/CocoaLumberjack/DDTTYLogger.h +++ /dev/null @@ -1,49 +0,0 @@ -#import - -#import "DDLog.h" - -/** - * Welcome to Cocoa Lumberjack! - * - * The Google Code page has a wealth of documentation if you have any questions. - * http://code.google.com/p/cocoalumberjack/ - * - * If you're new to the project you may wish to read the "Getting Started" page. - * http://code.google.com/p/cocoalumberjack/wiki/GettingStarted - * - * - * This class provides a logger for Terminal output or Xcode console output, - * depending on where you are running your code. - * - * As described in the "Getting Started" page, - * the traditional NSLog() function directs it's output to two places: - * - * - Apple System Log (so it shows up in Console.app) - * - StdErr (if stderr is a TTY, so log statements show up in Xcode console) - * - * To duplicate NSLog() functionality you can simply add this logger and an asl logger. - * However, if you instead choose to use file logging (for faster performance), - * you may choose to use only a file logger and a tty logger. -**/ - -@interface DDTTYLogger : DDAbstractLogger -{ - BOOL isaTTY; - - NSDateFormatter *dateFormatter; - - char *app; // Not null terminated - char *pid; // Not null terminated - - int appLen; - int pidLen; -} - -+ (DDTTYLogger *)sharedInstance; - -// Inherited from DDAbstractLogger - -// - (id )logFormatter; -// - (void)setLogFormatter:(id )formatter; - -@end diff --git a/Common/ThirdParty/CocoaLumberjack/DDTTYLogger.m b/Common/ThirdParty/CocoaLumberjack/DDTTYLogger.m deleted file mode 100755 index f84dbc2c..00000000 --- a/Common/ThirdParty/CocoaLumberjack/DDTTYLogger.m +++ /dev/null @@ -1,173 +0,0 @@ -#import "DDTTYLogger.h" - -#import -#import - - -@implementation DDTTYLogger - -static DDTTYLogger *sharedInstance; - -/** - * The runtime sends initialize to each class in a program exactly one time just before the class, - * or any class that inherits from it, is sent its first message from within the program. (Thus the - * method may never be invoked if the class is not used.) The runtime sends the initialize message to - * classes in a thread-safe manner. Superclasses receive this message before their subclasses. - * - * This method may also be called directly (assumably by accident), hence the safety mechanism. -**/ -+ (void)initialize -{ - static BOOL initialized = NO; - if (!initialized) - { - initialized = YES; - - sharedInstance = [[DDTTYLogger alloc] init]; - } -} - -+ (DDTTYLogger *)sharedInstance -{ - return sharedInstance; -} - -- (id)init -{ - if (sharedInstance != nil) - { - [self release]; - return nil; - } - - if ((self = [super init])) - { - isaTTY = isatty(STDERR_FILENO); - - if (isaTTY) - { - dateFormatter = [[NSDateFormatter alloc] init]; - [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4]; - [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss:SSS"]; - - // Initialze 'app' variable (char *) - - NSString *appNStr = [[NSProcessInfo processInfo] processName]; - const char *appCStr = [appNStr UTF8String]; - - appLen = strlen(appCStr); - - app = (char *)malloc(appLen); - strncpy(app, appCStr, appLen); // Not null terminated - - // Initialize 'pid' variable (char *) - - NSString *pidNStr = [NSString stringWithFormat:@"%i", (int)getpid()]; - const char *pidCStr = [pidNStr UTF8String]; - - pidLen = strlen(pidCStr); - - pid = (char *)malloc(pidLen); - strncpy(pid, pidCStr, pidLen); // Not null terminated - } - } - return self; -} - -- (void)logMessage:(DDLogMessage *)logMessage -{ - if (!isaTTY) return; - - NSString *logMsg = logMessage->logMsg; - BOOL isFormatted = NO; - - if (formatter) - { - logMsg = [formatter formatLogMessage:logMessage]; - isFormatted = logMsg != logMessage->logMsg; - } - - if (logMsg) - { - const char *msg = [logMsg UTF8String]; - int msgLen = strlen(msg); - - if (isFormatted) - { - struct iovec v[2]; - - v[0].iov_base = (char *)msg; - v[0].iov_len = msgLen; - - v[1].iov_base = "\n"; - v[1].iov_len = (msg[msgLen] == '\n') ? 0 : 1; - - writev(STDERR_FILENO, v, 2); - } - else - { - // The following is a highly optimized verion of file output to std err. - - // ts = timestamp - - NSString *tsNStr = [dateFormatter stringFromDate:(logMessage->timestamp)]; - - const char *tsCStr = [tsNStr UTF8String]; - int tsLen = strlen(tsCStr); - - // tid = thread id - // - // How many characters do we need for the thread id? - // logMessage->machThreadID is of type mach_port_t, which is an unsigned int. - // - // 1 hex char = 4 bits - // 8 hex chars for 32 bit, plus ending '\0' = 9 - - char tidCStr[9]; - int tidLen = snprintf(tidCStr, 9, "%x", logMessage->machThreadID); - - // Here is our format: "%s %s[%i:%s] %s", timestamp, appName, processID, threadID, logMsg - - struct iovec v[10]; - - v[0].iov_base = (char *)tsCStr; - v[0].iov_len = tsLen; - - v[1].iov_base = " "; - v[1].iov_len = 1; - - v[2].iov_base = app; - v[2].iov_len = appLen; - - v[3].iov_base = "["; - v[3].iov_len = 1; - - v[4].iov_base = pid; - v[4].iov_len = pidLen; - - v[5].iov_base = ":"; - v[5].iov_len = 1; - - v[6].iov_base = tidCStr; - v[6].iov_len = MIN(8, tidLen); // snprintf doesn't return what you might think - - v[7].iov_base = "] "; - v[7].iov_len = 2; - - v[8].iov_base = (char *)msg; - v[8].iov_len = msgLen; - - v[9].iov_base = "\n"; - v[9].iov_len = (msg[msgLen] == '\n') ? 0 : 1; - - writev(STDERR_FILENO, v, 10); - } - } -} - -- (NSString *)loggerName -{ - return @"cocoa.lumberjack.ttyLogger"; -} - -@end diff --git a/Common/ThirdParty/DDCli/DDCliApplication.m b/Common/ThirdParty/DDCli/DDCliApplication.m index 36f9c31a..da1cc320 100644 --- a/Common/ThirdParty/DDCli/DDCliApplication.m +++ b/Common/ThirdParty/DDCli/DDCliApplication.m @@ -53,17 +53,17 @@ - (id)init; return nil; NSProcessInfo * processInfo = [NSProcessInfo processInfo]; - _name = [[processInfo processName] retain]; + _name = [[processInfo processName] copy]; return self; } -- (void)dealloc -{ - [_name release]; - - [super dealloc]; -} +//- (void)dealloc +//{ +// [_name release]; +// +// [super dealloc]; +//} - (NSString *)name; { @@ -130,7 +130,7 @@ - (int)runWithClass:(Class)delegateClass return [self runWithDelegate:delegateInstance arguments:nil]; } @finally { - [delegateInstance release]; +// [delegateInstance release]; } } @@ -165,13 +165,19 @@ - (Class)findFirstDelegateClass; int DDCliAppRunWithClass(Class delegateClass) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - - // Initialize singleton/global - DDCliApplication * app = [DDCliApplication sharedApplication]; - int result = [app runWithClass: delegateClass]; - - [pool drain]; + int result; + @autoreleasepool { + // Initialize singleton/global + DDCliApplication * app = [DDCliApplication sharedApplication]; + result = [app runWithClass: delegateClass]; + } +// NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; +// +// // Initialize singleton/global +// DDCliApplication * app = [DDCliApplication sharedApplication]; +// int result = [app runWithClass: delegateClass]; +// +// [pool drain]; return result; } diff --git a/Common/ThirdParty/DDCli/DDCliParseException.m b/Common/ThirdParty/DDCli/DDCliParseException.m index d91d8c40..c0229a24 100644 --- a/Common/ThirdParty/DDCli/DDCliParseException.m +++ b/Common/ThirdParty/DDCli/DDCliParseException.m @@ -30,8 +30,10 @@ @implementation DDCliParseException + (DDCliParseException *)parseExceptionWithReason:(NSString *)reason exitCode:(int)exitCode; { - return [[[self alloc] initWithReason: reason - exitCode: exitCode] autorelease]; + @autoreleasepool { + return [[self alloc] initWithReason: reason + exitCode: exitCode]; + } } - (id)initWithReason:(NSString *)reason diff --git a/Common/ThirdParty/DDCli/DDCliUtil.m b/Common/ThirdParty/DDCli/DDCliUtil.m index 39873c2e..13fd9a7f 100644 --- a/Common/ThirdParty/DDCli/DDCliUtil.m +++ b/Common/ThirdParty/DDCli/DDCliUtil.m @@ -34,7 +34,7 @@ void ddfprintf(FILE * stream, NSString * format, ...) va_end(arguments); fprintf(stream, "%s", [string UTF8String]); - [string release]; +// [string release]; } void ddprintf(NSString * format, ...) @@ -46,5 +46,5 @@ void ddprintf(NSString * format, ...) va_end(arguments); printf("%s", [string UTF8String]); - [string release]; +// [string release]; } diff --git a/Common/ThirdParty/DDCli/DDGetoptLongParser.m b/Common/ThirdParty/DDCli/DDGetoptLongParser.m index eef44079..e8bc2c39 100644 --- a/Common/ThirdParty/DDCli/DDGetoptLongParser.m +++ b/Common/ThirdParty/DDCli/DDGetoptLongParser.m @@ -50,7 +50,10 @@ @implementation DDGetoptLongParser + (DDGetoptLongParser *)optionsWithTarget:(id)target; { - return [[[self alloc] initWithTarget: target] autorelease]; + @autoreleasepool { + return [[self alloc] initWithTarget: target]; + } + } - (id)initWithTarget:(id)target; @@ -73,15 +76,15 @@ - (id)initWithTarget:(id)target; return self; } -- (void)dealloc -{ - [_optionInfoMap release]; - [_optionString release]; - [_optionsData release]; - [_utf8Data release]; - - [super dealloc]; -} +//- (void)dealloc +//{ +// [_optionInfoMap release]; +// [_optionString release]; +// [_optionsData release]; +// [_utf8Data release]; +// +// [super dealloc]; +//} - (id)target; { diff --git a/Pods/Minizip/LICENSE b/Common/ThirdParty/DDMinizip/minizip/LICENSE similarity index 100% rename from Pods/Minizip/LICENSE rename to Common/ThirdParty/DDMinizip/minizip/LICENSE diff --git a/Pods/Minizip/crypt.c b/Common/ThirdParty/DDMinizip/minizip/crypt.c similarity index 100% rename from Pods/Minizip/crypt.c rename to Common/ThirdParty/DDMinizip/minizip/crypt.c diff --git a/Pods/Minizip/crypt.h b/Common/ThirdParty/DDMinizip/minizip/crypt.h similarity index 100% rename from Pods/Minizip/crypt.h rename to Common/ThirdParty/DDMinizip/minizip/crypt.h diff --git a/Pods/Minizip/ioapi.c b/Common/ThirdParty/DDMinizip/minizip/ioapi.c similarity index 100% rename from Pods/Minizip/ioapi.c rename to Common/ThirdParty/DDMinizip/minizip/ioapi.c diff --git a/Pods/Minizip/ioapi.h b/Common/ThirdParty/DDMinizip/minizip/ioapi.h similarity index 100% rename from Pods/Minizip/ioapi.h rename to Common/ThirdParty/DDMinizip/minizip/ioapi.h diff --git a/Pods/Minizip/ioapi_buf.c b/Common/ThirdParty/DDMinizip/minizip/ioapi_buf.c similarity index 95% rename from Pods/Minizip/ioapi_buf.c rename to Common/ThirdParty/DDMinizip/minizip/ioapi_buf.c index 8231608c..3e3dd9d2 100755 --- a/Pods/Minizip/ioapi_buf.c +++ b/Common/ThirdParty/DDMinizip/minizip/ioapi_buf.c @@ -207,7 +207,9 @@ uint32_t ZCALLBACK fread_buf_func(voidpf opaque, voidpf stream, void *buf, uint3 if ((streamio->readbuf_len - streamio->readbuf_pos) > 0) { - bytes_to_copy = min(bytes_left_to_read, (uint32_t)(streamio->readbuf_len - streamio->readbuf_pos)); + + bytes_to_copy = bytes_left_to_read < (uint32_t)(streamio->readbuf_len - streamio->readbuf_pos) ? bytes_left_to_read : (uint32_t)(streamio->readbuf_len - streamio->readbuf_pos); +// min(bytes_left_to_read, (uint32_t)(streamio->readbuf_len - streamio->readbuf_pos)); memcpy((char *)buf + buf_len, streamio->readbuf + streamio->readbuf_pos, bytes_to_copy); buf_len += bytes_to_copy; @@ -255,7 +257,11 @@ uint32_t ZCALLBACK fwrite_buf_func(voidpf opaque, voidpf stream, const void *buf while (bytes_left_to_write > 0) { - bytes_to_copy = min(bytes_left_to_write, (uint32_t)(IOBUF_BUFFERSIZE - min(streamio->writebuf_len, streamio->writebuf_pos))); + bytes_to_copy = bytes_left_to_write < (uint32_t)(IOBUF_BUFFERSIZE - + (streamio->writebuf_len < streamio->writebuf_pos ? streamio->writebuf_len : streamio->writebuf_pos)) + ? bytes_left_to_write : (uint32_t)(IOBUF_BUFFERSIZE - + (streamio->writebuf_len < streamio->writebuf_pos ? streamio->writebuf_len : streamio->writebuf_pos)); +// bytes_to_copy = min(bytes_left_to_write, (uint32_t)(IOBUF_BUFFERSIZE - min(streamio->writebuf_len, streamio->writebuf_pos))); if (bytes_to_copy == 0) { diff --git a/Pods/Minizip/ioapi_buf.h b/Common/ThirdParty/DDMinizip/minizip/ioapi_buf.h similarity index 100% rename from Pods/Minizip/ioapi_buf.h rename to Common/ThirdParty/DDMinizip/minizip/ioapi_buf.h diff --git a/Pods/Minizip/ioapi_mem.c b/Common/ThirdParty/DDMinizip/minizip/ioapi_mem.c similarity index 100% rename from Pods/Minizip/ioapi_mem.c rename to Common/ThirdParty/DDMinizip/minizip/ioapi_mem.c diff --git a/Pods/Minizip/ioapi_mem.h b/Common/ThirdParty/DDMinizip/minizip/ioapi_mem.h similarity index 100% rename from Pods/Minizip/ioapi_mem.h rename to Common/ThirdParty/DDMinizip/minizip/ioapi_mem.h diff --git a/Pods/Minizip/minishared.c b/Common/ThirdParty/DDMinizip/minizip/minishared.c similarity index 100% rename from Pods/Minizip/minishared.c rename to Common/ThirdParty/DDMinizip/minizip/minishared.c diff --git a/Pods/Minizip/minishared.h b/Common/ThirdParty/DDMinizip/minizip/minishared.h similarity index 100% rename from Pods/Minizip/minishared.h rename to Common/ThirdParty/DDMinizip/minizip/minishared.h diff --git a/Pods/Minizip/unzip.c b/Common/ThirdParty/DDMinizip/minizip/unzip.c similarity index 100% rename from Pods/Minizip/unzip.c rename to Common/ThirdParty/DDMinizip/minizip/unzip.c diff --git a/Pods/Minizip/unzip.h b/Common/ThirdParty/DDMinizip/minizip/unzip.h similarity index 100% rename from Pods/Minizip/unzip.h rename to Common/ThirdParty/DDMinizip/minizip/unzip.h diff --git a/Pods/Minizip/zip.c b/Common/ThirdParty/DDMinizip/minizip/zip.c similarity index 100% rename from Pods/Minizip/zip.c rename to Common/ThirdParty/DDMinizip/minizip/zip.c diff --git a/Pods/Minizip/zip.h b/Common/ThirdParty/DDMinizip/minizip/zip.h similarity index 100% rename from Pods/Minizip/zip.h rename to Common/ThirdParty/DDMinizip/minizip/zip.h diff --git a/Pods/DDMinizip/src/DDZipReader.h b/Common/ThirdParty/DDMinizip/src/DDZipReader.h similarity index 100% rename from Pods/DDMinizip/src/DDZipReader.h rename to Common/ThirdParty/DDMinizip/src/DDZipReader.h diff --git a/Pods/DDMinizip/src/DDZipReader.m b/Common/ThirdParty/DDMinizip/src/DDZipReader.m similarity index 100% rename from Pods/DDMinizip/src/DDZipReader.m rename to Common/ThirdParty/DDMinizip/src/DDZipReader.m diff --git a/Pods/DDMinizip/src/DDZipWriter.h b/Common/ThirdParty/DDMinizip/src/DDZipWriter.h similarity index 100% rename from Pods/DDMinizip/src/DDZipWriter.h rename to Common/ThirdParty/DDMinizip/src/DDZipWriter.h diff --git a/Pods/DDMinizip/src/DDZipWriter.m b/Common/ThirdParty/DDMinizip/src/DDZipWriter.m similarity index 100% rename from Pods/DDMinizip/src/DDZipWriter.m rename to Common/ThirdParty/DDMinizip/src/DDZipWriter.m diff --git a/Pods/DDMinizip/src/DDZippedFileInfo.h b/Common/ThirdParty/DDMinizip/src/DDZippedFileInfo.h similarity index 100% rename from Pods/DDMinizip/src/DDZippedFileInfo.h rename to Common/ThirdParty/DDMinizip/src/DDZippedFileInfo.h diff --git a/Pods/DDMinizip/src/DDZippedFileInfo.m b/Common/ThirdParty/DDMinizip/src/DDZippedFileInfo.m similarity index 100% rename from Pods/DDMinizip/src/DDZippedFileInfo.m rename to Common/ThirdParty/DDMinizip/src/DDZippedFileInfo.m diff --git a/Common/ThirdParty/DDUtils/DDXcodeProjectFile.m b/Common/ThirdParty/DDUtils/DDXcodeProjectFile.m index 097ccd65..f23a65d8 100644 --- a/Common/ThirdParty/DDUtils/DDXcodeProjectFile.m +++ b/Common/ThirdParty/DDUtils/DDXcodeProjectFile.m @@ -70,23 +70,41 @@ - (id)initWithName:(NSString*)name andDictionary:(NSDictionary*)dict { } + (id)xcodeProjectFileWithPath:(NSString*)path error:(NSError**)pError { - id file = [[[[self class] alloc] initWithPath:path] autorelease]; - if(file) { - if([file parse:pError]) { - return file; + @autoreleasepool { + id file = [[[self class] alloc] initWithPath:path]; + if(file) { + if([file parse:pError]) { + return file; + } } + return nil; } - return nil; +// id file = [[[[self class] alloc] initWithPath:path] autorelease]; +// if(file) { +// if([file parse:pError]) { +// return file; +// } +// } +// return nil; } + (id)xcodeProjectFileWithDictionary:(NSDictionary*)dict error:(NSError**)pError { - id file = [[[[self class] alloc] initWithDictionary:dict] autorelease]; - if(file) { - if([file parse:pError]) { - return file; + @autoreleasepool { + id file = [[[self class] alloc] initWithDictionary:dict]; + if(file) { + if([file parse:pError]) { + return file; + } } + return nil; } - return nil; +// id file = [[[[self class] alloc] initWithDictionary:dict] autorelease]; +// if(file) { +// if([file parse:pError]) { +// return file; +// } +// } +// return nil; } #pragma mark - main parse @@ -224,9 +242,14 @@ - (NSError*)parsePBXProject:(NSDictionary*)dict { - (NSError*)parsePBXFileReference:(NSDictionary*)dict { if(!dict[@"lastKnownFileType"] && dict[@"explicitFileType"]) { - NSMutableDictionary *mdict = [[dict mutableCopy] autorelease]; - mdict[@"lastKnownFileType"] = dict[@"explicitFileType"]; - dict = mdict; + @autoreleasepool { + NSMutableDictionary *mdict = [dict mutableCopy]; + mdict[@"lastKnownFileType"] = dict[@"explicitFileType"]; + dict = mdict; + } +// NSMutableDictionary *mdict = [[dict mutableCopy] autorelease]; +// mdict[@"lastKnownFileType"] = dict[@"explicitFileType"]; +// dict = mdict; } if(!dict[@"path"] || !dict[@"lastKnownFileType"]) { diff --git a/Common/ThirdParty/Miscellaneous/timing.h b/Common/ThirdParty/Miscellaneous/timing.h index c78c7545..bb95aa1f 100644 --- a/Common/ThirdParty/Miscellaneous/timing.h +++ b/Common/ThirdParty/Miscellaneous/timing.h @@ -63,6 +63,8 @@ #ifndef __TIMING_H__ #define __TIMING_H__ +#import + #include #include diff --git a/Generating/GBDocSetFinalizeGenerator.m b/Generating/GBDocSetFinalizeGenerator.m index ba373d5d..93dda4a3 100644 --- a/Generating/GBDocSetFinalizeGenerator.m +++ b/Generating/GBDocSetFinalizeGenerator.m @@ -19,7 +19,7 @@ @implementation GBDocSetFinalizeGenerator - (BOOL)generateOutputWithStore:(id)store error:(NSError **)error { NSParameterAssert(self.previousGenerator != nil); - GBLogInfo(@"Finalizing DocSet..."); +// GBLogInfo(@"Finalizing DocSet..."); // Prepare for run. if (![super generateOutputWithStore:store error:error]) return NO; @@ -31,13 +31,13 @@ - (BOOL)generateOutputWithStore:(id)store error:(NSError **)error { NSString *destPath = [destUserPath stringByStandardizingPath]; // Create destination directory and move files to it. - GBLogVerbose(@"Moving DocSet files from '%@' to '%@'...", sourceUserPath, destUserPath); +// GBLogVerbose(@"Moving DocSet files from '%@' to '%@'...", sourceUserPath, destUserPath); if (![self initializeDirectoryAtPath:destUserPath error:error]) { - GBLogWarn(@"Failed initializing DocSet installation directory '%@'!", destUserPath); +// GBLogWarn(@"Failed initializing DocSet installation directory '%@'!", destUserPath); return NO; } if (![self copyOrMoveItemFromPath:sourcePath toPath:destPath error:error]) { - GBLogWarn(@"Failed moving DocSet files from '%@' to '%@'!", sourceUserPath, destUserPath); +// GBLogWarn(@"Failed moving DocSet files from '%@' to '%@'!", sourceUserPath, destUserPath); return NO; } diff --git a/Generating/GBDocSetInstallGenerator.m b/Generating/GBDocSetInstallGenerator.m index e2ec1022..57f4b851 100644 --- a/Generating/GBDocSetInstallGenerator.m +++ b/Generating/GBDocSetInstallGenerator.m @@ -10,6 +10,7 @@ #import "GBStore.h" #import "GBTask.h" #import "GBDocSetInstallGenerator.h" +#import "NSError+GBError.h" @interface GBDocSetInstallGenerator () - (void)touchInstallMessageFile; @@ -23,7 +24,7 @@ @implementation GBDocSetInstallGenerator - (BOOL)generateOutputWithStore:(id)store error:(NSError **)error { NSParameterAssert(self.previousGenerator != nil); - GBLogInfo(@"Installing DocSet..."); +// GBLogInfo(@"Installing DocSet...%@", @""); // Prepare for run. if (![super generateOutputWithStore:store error:error]) return NO; @@ -36,7 +37,7 @@ - (BOOL)generateOutputWithStore:(id)store error:(NSError **)error { [self touchInstallMessageFile]; // Prepare AppleScript for loading the documentation into the Xcode. - GBLogVerbose(@"Installing DocSet to Xcode..."); +// GBLogVerbose(@"Installing DocSet to Xcode...%@", @""); NSMutableString* installScript = [NSMutableString string]; [installScript appendString:@"tell application \"Xcode\"\n"]; [installScript appendFormat:@"\tload documentation set with path \"%@\"\n", sourcePath]; @@ -63,7 +64,7 @@ - (void)touchInstallMessageFile { [message appendFormat:@"Time: %@", [NSDate date]]; NSError *error = nil; [message writeToFile:[filename stringByStandardizingPath] atomically:NO encoding:NSUTF8StringEncoding error:&error]; - if (error) GBLogNSError(error, @"Failed writing docset installed message file at '%@'!", filename); +// if (error) GBLogNSError(error, @"Failed writing docset installed message file at '%@'!", filename); } #pragma mark Overriden methods diff --git a/Generating/GBDocSetOutputGenerator.m b/Generating/GBDocSetOutputGenerator.m index 05e52dc8..69fe8dde 100644 --- a/Generating/GBDocSetOutputGenerator.m +++ b/Generating/GBDocSetOutputGenerator.m @@ -13,6 +13,9 @@ #import "GBDataObjects.h" #import "GBTemplateHandler.h" #import "GBDocSetOutputGenerator.h" +#import "NSError+GBError.h" +#import "NSObject+GBObject.h" +#import "NSException+GBException.h" typedef NS_ENUM(NSUInteger, GBDocSetNavigationTreeIconKind) { @@ -77,20 +80,20 @@ - (BOOL)generateOutputWithStore:(id)store error:(NSError **)error { } - (BOOL)copyOrMoveSourceFilesToDocuments:(NSError **)error { - GBLogInfo(@"Moving HTML files to DocSet bundle..."); +// GBLogInfo(@"Moving HTML files to DocSet bundle..."); // Prepare all paths. Note that we determine the exact subdirectory by searching for documents-template and using it's subdirectory as the guide. If documents template wasn't found, exit. NSString *sourceFilesPath = [self.inputUserPath stringByStandardizingPath]; NSString *documentsPath = [self outputPathToTemplateEndingWith:@"documents-template"]; if (!documentsPath) { if (error) *error = [NSError errorWithCode:GBErrorDocSetDocumentTemplateMissing description:@"Documents template is missing!" reason:@"documents-template file is required to determine location for Documents path in DocSet bundle!"]; - GBLogWarn(@"Failed finding documents-template in '%@'!", self.templateUserPath); +// GBLogWarn(@"Failed finding documents-template in '%@'!", self.templateUserPath); return NO; } // Copy or move all files generated by previous generator to documents subfolder of docset structure. if (![self copyOrMoveItemFromPath:sourceFilesPath toPath:documentsPath error:error]) { - GBLogWarn(@"Failed moving files from '%@' to '%@'!", self.previousGenerator.outputUserPath, documentsPath); +// GBLogWarn(@"Failed moving files from '%@' to '%@'!", self.previousGenerator.outputUserPath, documentsPath); return NO; } return YES; @@ -98,12 +101,12 @@ - (BOOL)copyOrMoveSourceFilesToDocuments:(NSError **)error { - (BOOL)processInfoPlist:(NSError **)error { #define addVarUnlessEmpty(var,key) if ([var length] > 0) [vars setObject:var forKey:key] - GBLogInfo(@"Writing DocSet Info.plist..."); +// GBLogInfo(@"Writing DocSet Info.plist..."); NSString *templateFilename = @"info-template.plist"; NSString *templatePath = [self templatePathForTemplateEndingWith:templateFilename]; if (!templatePath) { if (error) *error = [NSError errorWithCode:GBErrorDocSetInfoPlistTemplateMissing description:@"Info.plist template is missing!" reason:@"info-template.plist file is required to specify information about DocSet!"]; - GBLogWarn(@"Failed finding info-template.plist in '%@'!", self.templateUserPath); +// GBLogWarn(@"Failed finding info-template.plist in '%@'!", self.templateUserPath); return NO; } @@ -132,19 +135,19 @@ - (BOOL)processInfoPlist:(NSError **)error { NSString *outputPath = [self outputPathToTemplateEndingWith:templateFilename]; NSString *filename = [outputPath stringByAppendingPathComponent:@"Info.plist"]; if (![self writeString:output toFile:[filename stringByStandardizingPath] error:error]) { - GBLogWarn(@"Failed wrtting Info.plist to '%@'!", filename); +// GBLogWarn(@"Failed wrtting Info.plist to '%@'!", filename); return NO; } return YES; } - (BOOL)processNodesXml:(NSError **)error { - GBLogInfo(@"Writing DocSet Nodes.xml file..."); +// GBLogInfo(@"Writing DocSet Nodes.xml file..."); NSString *templateFilename = @"nodes-template.xml"; NSString *templatePath = [self templatePathForTemplateEndingWith:templateFilename]; if (!templatePath) { if (error) *error = [NSError errorWithCode:GBErrorDocSetNodesTemplateMissing description:@"Nodes.xml template is missing!" reason:@"nodes-template.xml file is required to specify document structure for DocSet!"]; - GBLogWarn(@"Failed finding nodes-template.xml in '%@'!", self.templateUserPath); +// GBLogWarn(@"Failed finding nodes-template.xml in '%@'!", self.templateUserPath); return NO; } @@ -173,19 +176,19 @@ - (BOOL)processNodesXml:(NSError **)error { NSString *filename = [outputPath stringByAppendingPathComponent:@"Nodes.xml"]; [self.temporaryFiles addObject:filename]; if (![self writeString:output toFile:[filename stringByStandardizingPath] error:error]) { - GBLogWarn(@"Failed writing Nodes.xml to '%@'!", filename); +// GBLogWarn(@"Failed writing Nodes.xml to '%@'!", filename); return NO; } return YES; } - (BOOL)processTokensXml:(NSError **)error { - GBLogInfo(@"Writing DocSet Tokens.xml files..."); +// GBLogInfo(@"Writing DocSet Tokens.xml files..."); // Get the template and prepare single Tokens.xml file for each object. NSString *templatePath = [self templatePathForTemplateEndingWith:@"tokens-template.xml"]; if (!templatePath) { - GBLogWarn(@"Didn't find tokens-template.xml in '%@', DocSet will not be indexed!", self.templateUserPath); +// GBLogWarn(@"Didn't find tokens-template.xml in '%@', DocSet will not be indexed!", self.templateUserPath); return YES; } @@ -201,20 +204,20 @@ - (BOOL)processTokensXml:(NSError **)error { } - (BOOL)indexDocSet:(NSError **)error { - GBLogInfo(@"Indexing DocSet..."); +// GBLogInfo(@"Indexing DocSet..."); GBTask *task = [GBTask task]; task.reportIndividualLines = YES; NSArray *args = @[@"docsetutil", @"index", [self.outputUserPath stringByStandardizingPath]]; BOOL result = [task runCommand:self.settings.xcrunPath arguments:args block:^(NSString *output, NSString *error) { - if (output) GBLogDebug(@"> %@", [output stringByTrimmingWhitespaceAndNewLine]); - if (error) GBLogError(@"!> %@", [error stringByTrimmingWhitespaceAndNewLine]); +// if (output) GBLogDebug(@"> %@", [output stringByTrimmingWhitespaceAndNewLine]); +// if (error) GBLogError(@"!> %@", [error stringByTrimmingWhitespaceAndNewLine]); }]; if (!result) { if (self.settings.treatDocSetIndexingErrorsAsFatals) { if (error) *error = [NSError errorWithCode:GBErrorDocSetUtilIndexingFailed description:@"docsetutil failed to index the documentation set!" reason:task.lastStandardError]; return NO; } else { - GBLogWarn(@"docsetutil failed to index the documentation set, continuing with what was indexed..."); +// GBLogWarn(@"docsetutil failed to index the documentation set, continuing with what was indexed..."); } } return YES; @@ -223,12 +226,12 @@ - (BOOL)indexDocSet:(NSError **)error { - (BOOL)removeTemporaryFiles:(NSError **)error { // We delete all registered temporary files and clear the list. If there are some problems, we simply log but always return YES - if these files remain, documentation set is still usable, so it's no point of aborting... Note that we keep all intermediate files if user has specified so. if (self.settings.keepIntermediateFiles) return YES; - GBLogInfo(@"Removing temporary DocSet files..."); +// GBLogInfo(@"Removing temporary DocSet files..."); NSError *err = nil; for (NSString *filename in self.temporaryFiles) { - GBLogDebug(@"Removing '%@'...", filename); +// GBLogDebug(@"Removing '%@'...", filename); if (![self.fileManager removeItemAtPath:[filename stringByStandardizingPath] error:&err]) { - GBLogNSError(err, @"Failed removing temporary file '%@'!", filename); +// GBLogNSError(err, @"Failed removing temporary file '%@'!", filename); } } return YES; @@ -301,7 +304,7 @@ - (BOOL)processTokensXmlForObjects:(NSArray *)objects type:(NSString *)type temp NSString *filename = [outputPath stringByAppendingPathComponent:indexName]; [self.temporaryFiles addObject:filename]; if (![self writeString:output toFile:[filename stringByStandardizingPath] error:error]) { - GBLogWarn(@"Failed writing tokens file '%@'!", filename); +// GBLogWarn(@"Failed writing tokens file '%@'!", filename); *index = idx; return NO; } @@ -473,7 +476,7 @@ - (NSString *)tokenIdentifierForObject:(GBModelBase *)object { - (void)initializeSimplifiedObjects { // Prepare flat list of objects for library nodes. - GBLogDebug(@"Initializing simplified object representations..."); +// GBLogDebug(@"Initializing simplified object representations..."); NSUInteger index = 1; self.documents = [self simplifiedObjectsFromObjects:[self.store documentsSortedByName] value:@"prettyNameOfDocument" index:&index]; self.classes = [self simplifiedObjectsFromObjects:[self.store classesSortedByName] value:@"nameOfClass" index:&index]; @@ -487,7 +490,7 @@ - (NSArray *)simplifiedObjectsFromObjects:(NSArray *)objects value:(NSString *)v NSUInteger idx = *index; NSMutableArray *result = [NSMutableArray arrayWithCapacity:[objects count]]; for (id object in objects) { - GBLogDebug(@"Initializing simplified representation of %@ with id %ld...", object, idx); +// GBLogDebug(@"Initializing simplified representation of %@ with id %ld...", object, idx); NSMutableDictionary *data = [NSMutableDictionary dictionaryWithCapacity:4]; data[@"object"] = object; data[@"id"] = [NSString stringWithFormat:@"%ld", idx++]; diff --git a/Generating/GBDocSetPublishGenerator.m b/Generating/GBDocSetPublishGenerator.m index 0d4fb042..828c667b 100644 --- a/Generating/GBDocSetPublishGenerator.m +++ b/Generating/GBDocSetPublishGenerator.m @@ -12,6 +12,7 @@ #import "GBDataObjects.h" #import "GBTemplateHandler.h" #import "GBDocSetPublishGenerator.h" +#import "NSError+GBError.h" @implementation GBDocSetPublishGenerator @@ -19,7 +20,7 @@ @implementation GBDocSetPublishGenerator - (BOOL)generateOutputWithStore:(id)store error:(NSError **)error { NSParameterAssert(self.previousGenerator != nil); - GBLogInfo(@"Preparing DocSet for publishing..."); +// GBLogInfo(@"Preparing DocSet for publishing..."); // Prepare for run. if (![super generateOutputWithStore:store error:error]) return NO; @@ -36,9 +37,9 @@ - (BOOL)generateOutputWithStore:(id)store error:(NSError **)error { if (!self.settings.installDocSet) { installedDocSetPath = [self.settings.outputPath stringByAppendingPathComponent:self.settings.docsetBundleFilename]; installedDocSetPath = [installedDocSetPath stringByStandardizingPath]; - GBLogVerbose(@"Moving DocSet files from '%@' to '%@'...", inputDocSetPath, installedDocSetPath); +// GBLogVerbose(@"Moving DocSet files from '%@' to '%@'...", inputDocSetPath, installedDocSetPath); if (![self copyOrMoveItemFromPath:inputDocSetPath toPath:installedDocSetPath error:error]) { - GBLogWarn(@"Failed moving DocSet files from '%@' to '%@'!", inputDocSetPath, installedDocSetPath); +// GBLogWarn(@"Failed moving DocSet files from '%@' to '%@'!", inputDocSetPath, installedDocSetPath); return NO; } } @@ -59,12 +60,12 @@ - (BOOL)generateOutputWithStore:(id)store error:(NSError **)error { if ([url length] == 0) { url = ([outputPaths count] > 0) ? outputPaths[0] : @""; - GBLogWarn(@"--docset-package-url is required for publishing DocSet; placeholder will be used in '%@'!", [outputPaths componentsJoinedByString:@", "]); +// GBLogWarn(@"--docset-package-url is required for publishing DocSet; placeholder will be used in '%@'!", [outputPaths componentsJoinedByString:@", "]); } // Create destination directory. if (![self initializeDirectoryAtPath:outputDir preserve:@[atomName] error:error]) { - GBLogWarn(@"Failed initializing DocSet publish directory '%@'!", outputDir); +// GBLogWarn(@"Failed initializing DocSet publish directory '%@'!", outputDir); return NO; } @@ -94,8 +95,8 @@ - (BOOL)generateOutputWithStore:(id)store error:(NSError **)error { // Run the task. BOOL result = [task runCommand:self.settings.xcrunPath arguments:args block:^(NSString *output, NSString *error) { - if (output) GBLogDebug(@"> %@", [output stringByTrimmingWhitespaceAndNewLine]); - if (error) GBLogError(@"!> %@", [error stringByTrimmingWhitespaceAndNewLine]); +// if (output) GBLogDebug(@"> %@", [output stringByTrimmingWhitespaceAndNewLine]); +// if (error) GBLogError(@"!> %@", [error stringByTrimmingWhitespaceAndNewLine]); }]; if (!result) { if (error) *error = [NSError errorWithCode:GBErrorDocSetUtilIndexingFailed description:@"docsetutil failed to package the documentation set!" reason:task.lastStandardError]; @@ -117,8 +118,8 @@ - (BOOL)generateOutputWithStore:(id)store error:(NSError **)error { // Run the task. BOOL result = [task runCommand:self.settings.xcrunPath arguments:args block:^(NSString *output, NSString *error) { - if (output) GBLogDebug(@"> %@", [output stringByTrimmingWhitespaceAndNewLine]); - if (error) GBLogError(@"!> %@", [error stringByTrimmingWhitespaceAndNewLine]); +// if (output) GBLogDebug(@"> %@", [output stringByTrimmingWhitespaceAndNewLine]); +// if (error) GBLogError(@"!> %@", [error stringByTrimmingWhitespaceAndNewLine]); }]; if (!result) { if (error) *error = [NSError errorWithCode:GBErrorDocSetUtilIndexingFailed description:@"tar failed to package the documentation set!" reason:task.lastStandardError]; diff --git a/Generating/GBGenerator.m b/Generating/GBGenerator.m index a3b08286..4534ea3e 100644 --- a/Generating/GBGenerator.m +++ b/Generating/GBGenerator.m @@ -38,7 +38,7 @@ + (id)generatorWithSettingsProvider:(id)settingsProvider { - (id)initWithSettingsProvider:(id)settingsProvider { NSParameterAssert(settingsProvider != nil); - GBLogDebug(@"Initializing generator with settings provider %@...", settingsProvider); +// GBLogDebug(@"Initializing generator with settings provider %@...", settingsProvider); self = [super init]; if (self) { self.settings = settingsProvider; @@ -50,14 +50,14 @@ - (id)initWithSettingsProvider:(id)settingsProvider { - (void)generateOutputFromStore:(id)aStore { NSParameterAssert(aStore != nil); - GBLogInfo(@"Generating output from parsed objects..."); +// GBLogInfo(@"Generating output from parsed objects..."); [self setupGeneratorStepsWithStore:aStore]; [self runGeneratorStepsWithStore:aStore]; } - (void)setupGeneratorStepsWithStore:(id)store { // Setups all output generators. The order of these is crucial as they are invoked in the order added to the list. This forms a dependency where each next generator can use - GBLogDebug(@"Initializing generation steps..."); +// GBLogDebug(@"Initializing generation steps..."); if (self.settings.createMarkdown) { [self.outputGenerators addObject:[GBMarkdownOutputGenerator generatorWithSettingsProvider:self.settings]]; } @@ -74,10 +74,10 @@ - (void)setupGeneratorStepsWithStore:(id)store { } - (void)runGeneratorStepsWithStore:(id)aStore { - GBLogDebug(@"Running generation steps..."); +// GBLogDebug(@"Running generation steps..."); NSUInteger stepsCount = [self.outputGenerators count]; if (stepsCount == 0) { - GBLogNormal(@"No generation step defined, ending."); +// GBLogNormal(@"No generation step defined, ending."); return; } @@ -85,15 +85,15 @@ - (void)runGeneratorStepsWithStore:(id)aStore { [self.outputGenerators enumerateObjectsUsingBlock:^(GBOutputGenerator *generator, NSUInteger idx, BOOL *stop) { NSError *error = nil; NSUInteger index = idx + 1; - GBLogVerbose(@"Generation step %ld/%ld: Running %@...", index, stepsCount, [generator className]); +// GBLogVerbose(@"Generation step %ld/%ld: Running %@...", index, stepsCount, [generator className]); generator.previousGenerator = previous; if (![generator copyTemplateFilesToOutputPath:&error]) { - GBLogNSError(error, @"Generation step %ld/%ld failed: %@ failed copying template files to output, aborting!", index, stepsCount, [generator className]); +// GBLogNSError(error, @"Generation step %ld/%ld failed: %@ failed copying template files to output, aborting!", index, stepsCount, [generator className]); *stop = YES; return; } if (![generator generateOutputWithStore:aStore error:&error]) { - GBLogNSError(error, @"Generation step %ld/%ld failed: %@ failed generating output, aborting!", index, stepsCount, [generator className]); +// GBLogNSError(error, @"Generation step %ld/%ld failed: %@ failed generating output, aborting!", index, stepsCount, [generator className]); *stop = YES; return; } @@ -106,7 +106,7 @@ - (void)runGeneratorStepsWithStore:(id)aStore { - (NSMutableArray *)outputGenerators { static NSMutableArray *result = nil; if (!result) { - GBLogDebug(@"Initializing output generators array..."); +// GBLogDebug(@"Initializing output generators array..."); result = [[NSMutableArray alloc] init]; } return result; diff --git a/Generating/GBHTMLOutputGenerator.m b/Generating/GBHTMLOutputGenerator.m index 95d34219..6ef480b2 100644 --- a/Generating/GBHTMLOutputGenerator.m +++ b/Generating/GBHTMLOutputGenerator.m @@ -12,6 +12,7 @@ #import "GBHTMLTemplateVariablesProvider.h" #import "GBTemplateHandler.h" #import "GBHTMLOutputGenerator.h" +#import "NSError+GBError.h" @interface GBHTMLOutputGenerator () @@ -60,16 +61,16 @@ - (BOOL)generateOutputWithStore:(id)store error:(NSError **)error { - (BOOL)processClasses:(NSError **)error { for (GBClassData *class in self.store.classes) { if (!class.includeInOutput) continue; - GBLogInfo(@"Generating output for class %@...", class); +// GBLogInfo(@"Generating output for class %@...", class); NSDictionary *vars = [self.variablesProvider variablesForClass:class withStore:self.store]; NSString *output = [self.htmlObjectTemplate renderObject:vars]; NSString *cleaned = [self stringByCleaningHtml:output]; NSString *path = [self htmlOutputPathForObject:class]; if (![self writeString:cleaned toFile:[path stringByStandardizingPath] error:error]) { - GBLogWarn(@"Failed writing HTML for class %@ to '%@'!", class, path); +// GBLogWarn(@"Failed writing HTML for class %@ to '%@'!", class, path); return NO; } - GBLogDebug(@"Finished generating output for class %@.", class); +// GBLogDebug(@"Finished generating output for class %@.", class); } return YES; } @@ -77,16 +78,16 @@ - (BOOL)processClasses:(NSError **)error { - (BOOL)processCategories:(NSError **)error { for (GBCategoryData *category in self.store.categories) { if (!category.includeInOutput) continue; - GBLogInfo(@"Generating output for category %@...", category); +// GBLogInfo(@"Generating output for category %@...", category); NSDictionary *vars = [self.variablesProvider variablesForCategory:category withStore:self.store]; NSString *output = [self.htmlObjectTemplate renderObject:vars]; NSString *cleaned = [self stringByCleaningHtml:output]; NSString *path = [self htmlOutputPathForObject:category]; if (![self writeString:cleaned toFile:[path stringByStandardizingPath] error:error]) { - GBLogWarn(@"Failed writing HTML for category %@ to '%@'!", category, path); +// GBLogWarn(@"Failed writing HTML for category %@ to '%@'!", category, path); return NO; } - GBLogDebug(@"Finished generating output for category %@.", category); +// GBLogDebug(@"Finished generating output for category %@.", category); } return YES; } @@ -94,16 +95,16 @@ - (BOOL)processCategories:(NSError **)error { - (BOOL)processProtocols:(NSError **)error { for (GBProtocolData *protocol in self.store.protocols) { if (!protocol.includeInOutput) continue; - GBLogInfo(@"Generating output for protocol %@...", protocol); +// GBLogInfo(@"Generating output for protocol %@...", protocol); NSDictionary *vars = [self.variablesProvider variablesForProtocol:protocol withStore:self.store]; NSString *output = [self.htmlObjectTemplate renderObject:vars]; NSString *cleaned = [self stringByCleaningHtml:output]; NSString *path = [self htmlOutputPathForObject:protocol]; if (![self writeString:cleaned toFile:[path stringByStandardizingPath] error:error]) { - GBLogWarn(@"Failed writing HTML for protocol %@ to '%@'!", protocol, path); +// GBLogWarn(@"Failed writing HTML for protocol %@ to '%@'!", protocol, path); return NO; } - GBLogDebug(@"Finished generating output for protocol %@.", protocol); +// GBLogDebug(@"Finished generating output for protocol %@.", protocol); } return YES; } @@ -111,16 +112,16 @@ - (BOOL)processProtocols:(NSError **)error { - (BOOL)processConstants:(NSError **)error { for (GBTypedefEnumData *enumTypedef in self.store.constants) { if (!enumTypedef.includeInOutput) continue; - GBLogInfo(@"Generating output for constant %@...", enumTypedef); +// GBLogInfo(@"Generating output for constant %@...", enumTypedef); NSDictionary *vars = [self.variablesProvider variablesForConstant:enumTypedef withStore:self.store]; NSString *output = [self.htmlObjectTemplate renderObject:vars]; NSString *cleaned = [self stringByCleaningHtml:output]; NSString *path = [self htmlOutputPathForObject:enumTypedef]; if (![self writeString:cleaned toFile:[path stringByStandardizingPath] error:error]) { - GBLogWarn(@"Failed writing HTML for constant %@ to '%@'!", enumTypedef, path); +// GBLogWarn(@"Failed writing HTML for constant %@ to '%@'!", enumTypedef, path); return NO; } - GBLogDebug(@"Finished generating output for constant %@.", enumTypedef); +// GBLogDebug(@"Finished generating output for constant %@.", enumTypedef); } return YES; } @@ -128,16 +129,16 @@ - (BOOL)processConstants:(NSError **)error { - (BOOL)processBlocks:(NSError **)error { for (GBTypedefBlockData *blockTypedef in self.store.blocks) { if (!blockTypedef.includeInOutput) continue; - GBLogInfo(@"Generating output for block %@...", blockTypedef); +// GBLogInfo(@"Generating output for block %@...", blockTypedef); NSDictionary *vars = [self.variablesProvider variablesForBlocks:blockTypedef withStore:self.store]; NSString *output = [self.htmlObjectTemplate renderObject:vars]; NSString *cleaned = [self stringByCleaningHtml:output]; NSString *path = [self htmlOutputPathForObject:blockTypedef]; if (![self writeString:cleaned toFile:[path stringByStandardizingPath] error:error]) { - GBLogWarn(@"Failed writing HTML for block %@ to '%@'!", blockTypedef, path); +// GBLogWarn(@"Failed writing HTML for block %@ to '%@'!", blockTypedef, path); return NO; } - GBLogDebug(@"Finished generating output for block %@.", blockTypedef); +// GBLogDebug(@"Finished generating output for block %@.", blockTypedef); } return YES; } @@ -147,7 +148,7 @@ - (BOOL)processDocuments:(NSError **)error { NSString *docsUserPath = [self.outputUserPath stringByAppendingPathComponent:self.settings.htmlStaticDocumentsSubpath]; GBTemplateFilesHandler *handler = [[GBTemplateFilesHandler alloc] init]; for (NSString *path in self.settings.includePaths) { - GBLogInfo(@"Copying static documents from '%@'...", path); +// GBLogInfo(@"Copying static documents from '%@'...", path); NSString *lastComponent = [path lastPathComponent]; NSString *installPath = [docsUserPath stringByAppendingPathComponent:lastComponent]; handler.templateUserPath = path; @@ -157,49 +158,49 @@ - (BOOL)processDocuments:(NSError **)error { // Now process all documents. for (GBDocumentData *document in self.store.documents) { - GBLogInfo(@"Generating output for document %@...", document); +// GBLogInfo(@"Generating output for document %@...", document); NSDictionary *vars = [self.variablesProvider variablesForDocument:document withStore:self.store]; NSString *output = [self.htmlDocumentTemplate renderObject:vars]; NSString *cleaned = [self stringByCleaningHtml:output]; NSString *path = [self htmlOutputPathForObject:document]; if (![self writeString:cleaned toFile:[path stringByStandardizingPath] error:error]) { - GBLogWarn(@"Failed writing HTML for document %@ to '%@'!", document, path); +// GBLogWarn(@"Failed writing HTML for document %@ to '%@'!", document, path); return NO; } - GBLogDebug(@"Finished generating output for document %@.", document); +// GBLogDebug(@"Finished generating output for document %@.", document); } return YES; } - (BOOL)processIndex:(NSError **)error { - GBLogInfo(@"Generating output for index..."); +// GBLogInfo(@"Generating output for index..."); if ([self.store.classes count] > 0 || [self.store.protocols count] > 0 || [self.store.categories count] > 0 || [self.store.constants count] > 0 || [self.store.blocks count] > 0) { NSDictionary *vars = [self.variablesProvider variablesForIndexWithStore:self.store]; NSString *output = [self.htmlIndexTemplate renderObject:vars]; NSString *cleaned = [self stringByCleaningHtml:output]; NSString *path = [[self htmlOutputPathForIndex] stringByStandardizingPath]; if (![self writeString:cleaned toFile:[path stringByStandardizingPath] error:error]) { - GBLogWarn(@"Failed writing HTML index to '%@'!", path); +// GBLogWarn(@"Failed writing HTML index to '%@'!", path); return NO; } } - GBLogDebug(@"Finished generating output for index."); +// GBLogDebug(@"Finished generating output for index."); return YES; } - (BOOL)processHierarchy:(NSError **)error { - GBLogInfo(@"Generating output for hierarchy..."); +// GBLogInfo(@"Generating output for hierarchy..."); if ([self.store.classes count] > 0 || [self.store.protocols count] > 0 || [self.store.categories count] > 0 || [self.store.constants count] > 0 || [self.store.blocks count] > 0) { NSDictionary *vars = [self.variablesProvider variablesForHierarchyWithStore:self.store]; NSString *output = [self.htmlHierarchyTemplate renderObject:vars]; NSString *cleaned = [self stringByCleaningHtml:output]; NSString *path = [[self htmlOutputPathForHierarchy] stringByStandardizingPath]; if (![self writeString:cleaned toFile:[path stringByStandardizingPath] error:error]) { - GBLogWarn(@"Failed writing HTML hierarchy to '%@'!", path); +// GBLogWarn(@"Failed writing HTML hierarchy to '%@'!", path); return NO; } } - GBLogDebug(@"Finished generating output for hierarchy."); +// GBLogDebug(@"Finished generating output for hierarchy."); return YES; } @@ -268,7 +269,7 @@ - (NSString *)htmlOutputPathForTemplateName:(NSString *)template { - (GBHTMLTemplateVariablesProvider *)variablesProvider { static GBHTMLTemplateVariablesProvider *result = nil; if (!result) { - GBLogDebug(@"Initializing variables provider..."); +// GBLogDebug(@"Initializing variables provider..."); result = [[GBHTMLTemplateVariablesProvider alloc] initWithSettingsProvider:self.settings]; } return result; diff --git a/Generating/GBHTMLTemplateVariablesProvider.h b/Generating/GBHTMLTemplateVariablesProvider.h index 48f42c59..69b26a5d 100644 --- a/Generating/GBHTMLTemplateVariablesProvider.h +++ b/Generating/GBHTMLTemplateVariablesProvider.h @@ -7,6 +7,11 @@ // #import +#import "GBCategoryData.h" +#import "GBProtocolData.h" +#import "GBTypedefEnumData.h" +#import "GBDocumentData.h" +#import "GBTypedefBlockData.h" @class GBClassData; diff --git a/Generating/GBHTMLTemplateVariablesProvider.m b/Generating/GBHTMLTemplateVariablesProvider.m index 89690ae7..b84a0ccd 100644 --- a/Generating/GBHTMLTemplateVariablesProvider.m +++ b/Generating/GBHTMLTemplateVariablesProvider.m @@ -94,7 +94,7 @@ + (id)providerWithSettingsProvider:(id)settingsProvider { - (id)initWithSettingsProvider:(id)settingsProvider { NSParameterAssert(settingsProvider != nil); - GBLogDebug(@"Initializing variables provider with settings provider %@...", settingsProvider); +// GBLogDebug(@"Initializing variables provider with settings provider %@...", settingsProvider); self = [super init]; if (self) { self.settings = settingsProvider; diff --git a/Generating/GBMarkdownOutputGenerator.m b/Generating/GBMarkdownOutputGenerator.m index 0e3b5279..17e01448 100644 --- a/Generating/GBMarkdownOutputGenerator.m +++ b/Generating/GBMarkdownOutputGenerator.m @@ -12,6 +12,7 @@ #import "GBDataObjects.h" #import "GBHTMLTemplateVariablesProvider.h" #import "GBTemplateHandler.h" +#import "NSError+GBError.h" @interface GBMarkdownOutputGenerator () @@ -46,16 +47,16 @@ - (BOOL)generateOutputWithStore:(id)store error:(NSError **)error { - (BOOL)processClasses:(NSError **)error { for (GBClassData *class in self.store.classes) { if (!class.includeInOutput) continue; - GBLogInfo(@"Generating output for class %@...", class); +// GBLogInfo(@"Generating output for class %@...", class); NSDictionary *vars = [self.variablesProvider variablesForClass:class withStore:self.store]; NSString *output = [self.markdownTemplate renderObject:vars]; NSString *cleaned = [self stringByCleaningHtml:output]; NSString *path = [self markdownOutputPathForObject:class]; if (![self writeString:cleaned toFile:[path stringByStandardizingPath] error:error]) { - GBLogWarn(@"Failed writing markdown for class %@ to '%@'!", class, path); +// GBLogWarn(@"Failed writing markdown for class %@ to '%@'!", class, path); return NO; } - GBLogDebug(@"Finished generating output for class %@.", class); +// GBLogDebug(@"Finished generating output for class %@.", class); } return YES; } @@ -63,16 +64,16 @@ - (BOOL)processClasses:(NSError **)error { - (BOOL)processCategories:(NSError **)error { for (GBCategoryData *category in self.store.categories) { if (!category.includeInOutput) continue; - GBLogInfo(@"Generating output for category %@...", category); +// GBLogInfo(@"Generating output for category %@...", category); NSDictionary *vars = [self.variablesProvider variablesForCategory:category withStore:self.store]; NSString *output = [self.markdownTemplate renderObject:vars]; NSString *cleaned = [self stringByCleaningHtml:output]; NSString *path = [self markdownOutputPathForObject:category]; if (![self writeString:cleaned toFile:[path stringByStandardizingPath] error:error]) { - GBLogWarn(@"Failed writing markdown for category %@ to '%@'!", category, path); +// GBLogWarn(@"Failed writing markdown for category %@ to '%@'!", category, path); return NO; } - GBLogDebug(@"Finished generating output for category %@.", category); +// GBLogDebug(@"Finished generating output for category %@.", category); } return YES; } @@ -80,16 +81,16 @@ - (BOOL)processCategories:(NSError **)error { - (BOOL)processProtocols:(NSError **)error { for (GBProtocolData *protocol in self.store.protocols) { if (!protocol.includeInOutput) continue; - GBLogInfo(@"Generating output for protocol %@...", protocol); +// GBLogInfo(@"Generating output for protocol %@...", protocol); NSDictionary *vars = [self.variablesProvider variablesForProtocol:protocol withStore:self.store]; NSString *output = [self.markdownTemplate renderObject:vars]; NSString *cleaned = [self stringByCleaningHtml:output]; NSString *path = [self markdownOutputPathForObject:protocol]; if (![self writeString:cleaned toFile:[path stringByStandardizingPath] error:error]) { - GBLogWarn(@"Failed writing markdown for protocol %@ to '%@'!", protocol, path); +// GBLogWarn(@"Failed writing markdown for protocol %@ to '%@'!", protocol, path); return NO; } - GBLogDebug(@"Finished generating output for protocol %@.", protocol); +// GBLogDebug(@"Finished generating output for protocol %@.", protocol); } return YES; } @@ -97,16 +98,16 @@ - (BOOL)processProtocols:(NSError **)error { - (BOOL)processConstants:(NSError **)error { for (GBTypedefEnumData *enumTypedef in self.store.constants) { if (!enumTypedef.includeInOutput) continue; - GBLogInfo(@"Generating output for constant %@...", enumTypedef); +// GBLogInfo(@"Generating output for constant %@...", enumTypedef); NSDictionary *vars = [self.variablesProvider variablesForConstant:enumTypedef withStore:self.store]; NSString *output = [self.markdownTemplate renderObject:vars]; NSString *cleaned = [self stringByCleaningHtml:output]; NSString *path = [self markdownOutputPathForObject:enumTypedef]; if (![self writeString:cleaned toFile:[path stringByStandardizingPath] error:error]) { - GBLogWarn(@"Failed writing markdown for constant %@ to '%@'!", enumTypedef, path); +// GBLogWarn(@"Failed writing markdown for constant %@ to '%@'!", enumTypedef, path); return NO; } - GBLogDebug(@"Finished generating output for constant %@.", enumTypedef); +// GBLogDebug(@"Finished generating output for constant %@.", enumTypedef); } return YES; } @@ -114,16 +115,16 @@ - (BOOL)processConstants:(NSError **)error { - (BOOL)processBlocks:(NSError **)error { for (GBTypedefBlockData *blockTypedef in self.store.blocks) { if (!blockTypedef.includeInOutput) continue; - GBLogInfo(@"Generating output for block %@...", blockTypedef); +// GBLogInfo(@"Generating output for block %@...", blockTypedef); NSDictionary *vars = [self.variablesProvider variablesForBlocks:blockTypedef withStore:self.store]; NSString *output = [self.markdownTemplate renderObject:vars]; NSString *cleaned = [self stringByCleaningHtml:output]; NSString *path = [self markdownOutputPathForObject:blockTypedef]; if (![self writeString:cleaned toFile:[path stringByStandardizingPath] error:error]) { - GBLogWarn(@"Failed writing markdown for block %@ to '%@'!", blockTypedef, path); +// GBLogWarn(@"Failed writing markdown for block %@ to '%@'!", blockTypedef, path); return NO; } - GBLogDebug(@"Finished generating output for block %@.", blockTypedef); +// GBLogDebug(@"Finished generating output for block %@.", blockTypedef); } return YES; } @@ -166,7 +167,7 @@ - (NSString *)markdownOutputPathForObject:(GBModelBase *)object { - (GBHTMLTemplateVariablesProvider *)variablesProvider { static GBHTMLTemplateVariablesProvider *result = nil; if (!result) { - GBLogDebug(@"Initializing variables provider..."); +// GBLogDebug(@"Initializing variables provider..."); result = [[GBHTMLTemplateVariablesProvider alloc] initWithSettingsProvider:self.settings]; } return result; diff --git a/Generating/GBOutputGenerator.m b/Generating/GBOutputGenerator.m index 9492a60b..c8ed2d43 100644 --- a/Generating/GBOutputGenerator.m +++ b/Generating/GBOutputGenerator.m @@ -10,6 +10,7 @@ #import "GBApplicationSettingsProvider.h" #import "GBTemplateHandler.h" #import "GBOutputGenerator.h" +#import "NSObject+GBObject.h" @interface GBOutputGenerator () @@ -29,7 +30,7 @@ + (id)generatorWithSettingsProvider:(id)settingsProvider { - (id)initWithSettingsProvider:(id)settingsProvider { NSParameterAssert(settingsProvider != nil); - GBLogDebug(@"Initializing output generator with settings provider %@...", settingsProvider); +// GBLogDebug(@"Initializing output generator with settings provider %@...", settingsProvider); self = [super init]; if (self) { self.settings = settingsProvider; @@ -40,7 +41,7 @@ - (id)initWithSettingsProvider:(id)settingsProvider { #pragma mark Generation handling - (BOOL)generateOutputWithStore:(id)aStore error:(NSError **)error { - GBLogVerbose(@"%@ is generating output...", [self className]); +// GBLogVerbose(@"%@ is generating output...", [self className]); self.store = aStore; return YES; } @@ -50,23 +51,23 @@ - (BOOL)initializeDirectoryAtPath:(NSString *)path error:(NSError **)error { } - (BOOL)initializeDirectoryAtPath:(NSString *)path preserve:(NSArray *)preserve error:(NSError **)error { - GBLogVerbose(@"Initializing directory at '%@'...", path); +// GBLogVerbose(@"Initializing directory at '%@'...", path); NSString *standardized = [path stringByStandardizingPath]; // If no path is to be preserved, just use simple approach of removing path and recreating it later on... Otherwise delete all content except given one. BOOL exists = [self.fileManager fileExistsAtPath:standardized]; if ([preserve count] == 0) { if (exists) { - GBLogDebug(@"Removing existing directory..."); +// GBLogDebug(@"Removing existing directory..."); if (![self.fileManager removeItemAtPath:standardized error:error]) return NO; } } else if (exists) { - GBLogDebug(@"Enumerating directory contents..."); +// GBLogDebug(@"Enumerating directory contents..."); NSArray *contents = [self.fileManager contentsOfDirectoryAtPath:standardized error:error]; if (!contents && error && *error) return NO; for (NSString *subpath in contents) { if (![preserve containsObject:subpath]) { - GBLogDebug(@"Removing '%@'...", subpath); +// GBLogDebug(@"Removing '%@'...", subpath); if (![self.fileManager removeItemAtPath:[path stringByAppendingPathComponent:subpath] error:error]) return NO; } } @@ -74,7 +75,7 @@ - (BOOL)initializeDirectoryAtPath:(NSString *)path preserve:(NSArray *)preserve // Create the directory if it doesn't yet exist. Note that we rely on system to actually check if the directory exists, instead of the cached value from above. The cached value may change if we remove the directory. Although we could change the value too, it makes tool safer this way. if (![self.fileManager fileExistsAtPath:standardized]) { - GBLogDebug(@"Creating directory..."); +// GBLogDebug(@"Creating directory..."); return [self.fileManager createDirectoryAtPath:standardized withIntermediateDirectories:YES attributes:nil error:error]; } return YES; @@ -82,16 +83,16 @@ - (BOOL)initializeDirectoryAtPath:(NSString *)path preserve:(NSArray *)preserve - (BOOL)copyOrMoveItemFromPath:(NSString *)source toPath:(NSString *)destination error:(NSError **)error { BOOL copy = self.settings.keepIntermediateFiles; - GBLogDebug(@"%@ '%@' to '%@'...", copy ? @"Copying" : @"Moving", source, destination); +// GBLogDebug(@"%@ '%@' to '%@'...", copy ? @"Copying" : @"Moving", source, destination); NSString *standardSource = [source stringByStandardizingPath]; NSString *standardDest = [destination stringByStandardizingPath]; // We must first delete destination path if it exists. Otherwise copy or move will fail! if ([self.fileManager fileExistsAtPath:standardDest]) { - GBLogDebug(@"Removing '%@'...", destination); +// GBLogDebug(@"Removing '%@'...", destination); if (![self.fileManager removeItemAtPath:standardDest error:error]) { - GBLogWarn(@"Failed removing '%@'!", destination); +// GBLogWarn(@"Failed removing '%@'!", destination); return NO; } } @@ -107,12 +108,12 @@ - (BOOL)writeString:(NSString *)string toFile:(NSString *)path error:(NSError ** NSString *standardized = [path stringByStandardizingPath]; NSString *directory = [standardized stringByDeletingLastPathComponent]; if (![self.fileManager createDirectoryAtPath:directory withIntermediateDirectories:YES attributes:nil error:error]) { - GBLogWarn(@"Failed creating directory while writing '%@'!", path); +// GBLogWarn(@"Failed creating directory while writing '%@'!", path); return NO; } if (![string writeToFile:standardized atomically:YES encoding:NSUTF8StringEncoding error:error]) { - GBLogWarn(@"Failed writing '%@'!", path); +// GBLogWarn(@"Failed writing '%@'!", path); return NO; } diff --git a/Generating/GBTemplateFilesHandler.m b/Generating/GBTemplateFilesHandler.m index 9fad8993..47f7e8e0 100644 --- a/Generating/GBTemplateFilesHandler.m +++ b/Generating/GBTemplateFilesHandler.m @@ -8,6 +8,8 @@ #import "GBTemplateHandler.h" #import "GBTemplateFilesHandler.h" +//#import "GBLog.h" +#import "NSObject+GBObject.h" @interface GBTemplateFilesHandler () @@ -42,13 +44,13 @@ - (BOOL)copyTemplateFilesToOutputPath:(NSError **)error { NSString *destUserPath = self.outputUserPath; NSString *sourcePath = [sourceUserPath stringByStandardizingPath]; NSString *destPath = [destUserPath stringByStandardizingPath]; - GBLogVerbose(@"Copying template files from '%@' to '%@'...", sourceUserPath, destUserPath); +// GBLogVerbose(@"Copying template files from '%@' to '%@'...", sourceUserPath, destUserPath); // Remove destination path if it exists. Exit if we fail. if ([self.fileManager fileExistsAtPath:destPath]) { - GBLogDebug(@"Removing output at '%@'...", destUserPath); +// GBLogDebug(@"Removing output at '%@'...", destUserPath); if (![self.fileManager removeItemAtPath:destPath error:error]) { - GBLogWarn(@"Failed removing output files at '%@'!", destUserPath); +// GBLogWarn(@"Failed removing output files at '%@'!", destUserPath); return NO; } } @@ -56,39 +58,39 @@ - (BOOL)copyTemplateFilesToOutputPath:(NSError **)error { // Create directory hierarchy minus the last one. This is necessary if more than one component is missing at destination path; copyItemAtPath:toPath:error would fail in such case. Note that we can't create the last directory as mentioned method request is that the destination doesn't exist! NSString *createDestPath = [destPath stringByDeletingLastPathComponent]; if (![self.fileManager createDirectoryAtPath:createDestPath withIntermediateDirectories:YES attributes:nil error:error]) { - GBLogWarn(@"Failed creating directory '%@'!", createDestPath); +// GBLogWarn(@"Failed creating directory '%@'!", createDestPath); return NO; } // If there's no source file, there also no need to copy anything, so exit. In fact, copying would probably just result in errors. if (![self.fileManager fileExistsAtPath:sourcePath]) { - GBLogDebug(@"No template file found at '%@', no need to copy.", sourceUserPath); +// GBLogDebug(@"No template file found at '%@', no need to copy.", sourceUserPath); return YES; } // Copy the whole source directory over to output. Exit if we fail. - GBLogDebug(@"Copying template files from '%@' to '%@'...", sourceUserPath, destUserPath); +// GBLogDebug(@"Copying template files from '%@' to '%@'...", sourceUserPath, destUserPath); if (![self.fileManager copyItemAtPath:sourcePath toPath:destPath error:error]) { - GBLogWarn(@"Failed copying templates from '%@' to '%@'!", sourceUserPath, destUserPath); +// GBLogWarn(@"Failed copying templates from '%@' to '%@'!", sourceUserPath, destUserPath); return NO; } // Remove all ignored files and special template items from output. First enumerate all files. If this fails, report success; this step is only used to verscleanup the destination, we should still have valid output if these files are kept there. Note that we need to test for existing file before removing as it could happen file's parent dir was removed already in previous iterations so the file or subdir doesn't exist anymore - see https://github.com/tomaz/appledoc/issues#issue/59 for details. - GBLogDebug(@"Removing temporary files from '%@'...", destUserPath); +// GBLogDebug(@"Removing temporary files from '%@'...", destUserPath); NSArray *items = [self.fileManager subpathsOfDirectoryAtPath:destPath error:error]; if (!items) { - GBLogWarn(@"Failed enumerating template files at '%@'!", destUserPath); +// GBLogWarn(@"Failed enumerating template files at '%@'!", destUserPath); return YES; } for (NSString *path in items) { BOOL delete = NO; if ([self isPathRepresentingIgnoredFile:path]) { - GBLogDebug(@"Removing ignored file '%@' from output...", path); +// GBLogDebug(@"Removing ignored file '%@' from output...", path); delete = YES; } else if ([self isPathRepresentingTemplateFile:path]) { GBTemplateHandler *handler = [self templateHandlerFromTemplateFile:path error:error]; if (!handler) return NO; - GBLogDebug(@"Removing template file '%@' from output...", path); +// GBLogDebug(@"Removing template file '%@' from output...", path); self.templateFiles[path] = handler; delete = YES; } @@ -96,7 +98,7 @@ - (BOOL)copyTemplateFilesToOutputPath:(NSError **)error { if (delete) { NSString *fullpath = [destPath stringByAppendingPathComponent:path]; if ([self.fileManager fileExistsAtPath:fullpath] && ![self.fileManager removeItemAtPath:fullpath error:error]) { - GBLogWarn(@"Can't clean leftover '%@' from '%@'.", path, destUserPath); +// GBLogWarn(@"Can't clean leftover '%@' from '%@'.", path, destUserPath); } } } @@ -124,10 +126,10 @@ - (NSString *)outputPathToTemplateEndingWith:(NSString *)suffix { - (GBTemplateHandler *)templateHandlerFromTemplateFile:(NSString *)filename error:(NSError **)error { NSString *path = [[self templateUserPath] stringByAppendingPathComponent:filename]; - GBLogDebug(@"Creating template handler for template file '%@'...", path); +// GBLogDebug(@"Creating template handler for template file '%@'...", path); GBTemplateHandler *result = [GBTemplateHandler handler]; if (![result parseTemplateFromPath:[path stringByStandardizingPath] error:error]) { - GBLogWarn(@"Failed parsing template '%@'!", filename); +// GBLogWarn(@"Failed parsing template '%@'!", filename); return nil; } return result; diff --git a/Generating/GBTemplateHandler.m b/Generating/GBTemplateHandler.m index a3aa75fd..2faf5069 100644 --- a/Generating/GBTemplateHandler.m +++ b/Generating/GBTemplateHandler.m @@ -9,6 +9,8 @@ #import #import #import "GBTemplateHandler.h" +#import "NSString+GBString.h" +//#import "GBLog.h" static NSString *kGBSectionKey = @"section"; static NSString *kGBNameKey = @"name"; @@ -49,11 +51,11 @@ - (id)init { #pragma mark Parsing handling - (BOOL)parseTemplateFromPath:(NSString *)path error:(NSError **)error { - GBLogVerbose(@"Parsing template from %@...", path); +// GBLogVerbose(@"Parsing template from %@...", path); [self clearParsedValues]; NSString *template = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:error]; if (!template) { - if (error) GBLogNSError(*error, @"Loading template %@ failed!", path); +// if (error) GBLogNSError(*error, @"Loading template %@ failed!", path); return NO; } return [self parseTemplate:template error:error]; @@ -78,8 +80,8 @@ - (BOOL)parseTemplate:(NSString *)template error:(NSError **)error { } // If the section is valid, log it. - NSUInteger line = [self lineOfSectionData:sectionData withinTemplate:template]; - GBLogDebug(@"Found section template %@ at line %ld...", sectionData[kGBNameKey], line); +// NSUInteger line = [self lineOfSectionData:sectionData withinTemplate:template]; +// GBLogDebug(@"Found section template %@ at line %ld...", sectionData[kGBNameKey], line); // Get the range of the regex within the clean string and remove the substring from it. NSString *section = sectionData[kGBSectionKey]; @@ -92,7 +94,7 @@ - (BOOL)parseTemplate:(NSString *)template error:(NSError **)error { } // Prepare template string and warn if it's empty. - if ([clean length] == 0) GBLogWarn(@"Template contains empty string (with %ld template sections)!", [_templateSections count]); +// if ([clean length] == 0) GBLogWarn(@"Template contains empty string (with %ld template sections)!", [_templateSections count]); _templateString = [clean copy]; // Prepare template that will be used for rendering output. @@ -108,15 +110,15 @@ - (BOOL)parseTemplate:(NSString *)template error:(NSError **)error { #pragma Rendering handling - (NSString *)renderObject:(id)object { - GBLogVerbose(@"Rendering %@...", [[object description] normalizedDescription]); +// GBLogVerbose(@"Rendering %@...", [[object description] normalizedDescription]); if (!_template) { - GBLogWarn(@"No template loaded or parsed, ignoring redering!"); +// GBLogWarn(@"No template loaded or parsed, ignoring redering!"); return @""; } NSError* error = nil; NSString* rendering = [_template renderObject:object error:&error]; if (error) { - GBLogWarn(@"Error occurred when rendering template: %@", [error localizedDescription]); +// GBLogWarn(@"Error occurred when rendering template: %@", [error localizedDescription]); } return rendering; } @@ -126,15 +128,15 @@ - (NSString *)renderObject:(id)object { - (BOOL)validateSectionData:(NSDictionary *)data withTemplate:(NSString *)template { NSString *name = data[kGBNameKey]; if ([name length] == 0) { - NSUInteger line = [self lineOfSectionData:data withinTemplate:template]; - GBLogWarn(@"Unnamed section found at line %ld, ignoring!", line); +// NSUInteger line = [self lineOfSectionData:data withinTemplate:template]; +// GBLogWarn(@"Unnamed section found at line %ld, ignoring!", line); return NO; } NSString *value = [data[kGBValueKey] stringByTrimmingWhitespace]; if ([value length] == 0) { - NSUInteger line = [self lineOfSectionData:data withinTemplate:template]; - GBLogWarn(@"Empty section %@ found at line %ld, ignoring!", name, line); +// NSUInteger line = [self lineOfSectionData:data withinTemplate:template]; +// GBLogWarn(@"Empty section %@ found at line %ld, ignoring!", name, line); return NO; } @@ -148,7 +150,7 @@ - (NSUInteger)lineOfSectionData:(NSDictionary *)data withinTemplate:(NSString *) } - (void)clearParsedValues { - GBLogDebug(@"Clearing parsed values..."); +// GBLogDebug(@"Clearing parsed values..."); _template = nil; _templateString = @""; [_templateSections removeAllObjects]; diff --git a/Model/GBAdoptedProtocolsProvider.m b/Model/GBAdoptedProtocolsProvider.m index db54b043..9e7bab97 100644 --- a/Model/GBAdoptedProtocolsProvider.m +++ b/Model/GBAdoptedProtocolsProvider.m @@ -8,6 +8,7 @@ #import "GBProtocolData.h" #import "GBAdoptedProtocolsProvider.h" +#import "NSException+GBException.h" @implementation GBAdoptedProtocolsProvider @@ -15,7 +16,7 @@ @implementation GBAdoptedProtocolsProvider - (id)initWithParentObject:(id)parent { NSParameterAssert(parent != nil); - GBLogDebug(@"Initializing adopted protocols provider for %@...", parent); +// GBLogDebug(@"Initializing adopted protocols provider for %@...", parent); self = [super init]; if (self) { _parent = parent; @@ -34,7 +35,7 @@ - (id)init { - (void)registerProtocol:(GBProtocolData *)protocol { NSParameterAssert(protocol != nil); - GBLogDebug(@"%@: Registering protocol %@...", _parent, protocol); +// GBLogDebug(@"%@: Registering protocol %@...", _parent, protocol); if ([_protocols containsObject:protocol]) return; GBProtocolData *existingProtocol = _protocolsByName[protocol.nameOfProtocol]; if (existingProtocol) { @@ -49,7 +50,7 @@ - (void)registerProtocol:(GBProtocolData *)protocol { - (void)mergeDataFromProtocolsProvider:(GBAdoptedProtocolsProvider *)source { if (!source || source == self) return; - GBLogDebug(@"%@: Merging adopted protocols from %@...", _parent, source->_parent); +// GBLogDebug(@"%@: Merging adopted protocols from %@...", _parent, source->_parent); for (GBProtocolData *sourceProtocol in source.protocols) { GBProtocolData *existingProtocol = _protocolsByName[sourceProtocol.nameOfProtocol]; if (existingProtocol) { diff --git a/Model/GBCategoryData.m b/Model/GBCategoryData.m index 332782c4..05fc4c75 100644 --- a/Model/GBCategoryData.m +++ b/Model/GBCategoryData.m @@ -19,7 +19,7 @@ + (id)categoryDataWithName:(NSString *)name className:(NSString *)className { - (id)initWithName:(NSString *)name className:(NSString *)className { NSParameterAssert(className && [className length] > 0); - GBLogDebug(@"Initializing %@%@ for class %@...", name ? @"category " : @"extension", name ? name : @"", className); +// GBLogDebug(@"Initializing %@%@ for class %@...", name ? @"category " : @"extension", name ? name : @"", className); self = [super init]; if (self) { _categoryName = name ? [name copy] : nil; @@ -34,7 +34,7 @@ - (id)initWithName:(NSString *)name className:(NSString *)className { - (void)mergeDataFromObject:(id)source { if (!source || source == self) return; - GBLogDebug(@"%@: Merging data from %@...", self, source); +// GBLogDebug(@"%@: Merging data from %@...", self, source); NSParameterAssert([[source nameOfClass] isEqualToString:self.nameOfClass]); NSParameterAssert([source nameOfCategory] == self.nameOfCategory || [[source nameOfCategory] isEqualToString:self.nameOfCategory]); // allow nil for extensions! [super mergeDataFromObject:source]; diff --git a/Model/GBClassData.m b/Model/GBClassData.m index 9e4c2338..e745e249 100644 --- a/Model/GBClassData.m +++ b/Model/GBClassData.m @@ -19,7 +19,7 @@ + (id)classDataWithName:(NSString *)name { - (id)initWithName:(NSString *)name { NSParameterAssert(name != nil && [name length] > 0); - GBLogDebug(@"Initializing class with name %@...", name); +// GBLogDebug(@"Initializing class with name %@...", name); self = [super init]; if (self) { _className = [name copy]; @@ -34,7 +34,7 @@ - (id)initWithName:(NSString *)name { - (void)mergeDataFromObject:(id)source { if (!source || source == self) return; - GBLogDebug(@"%@: Merging data from %@...", self, source); +// GBLogDebug(@"%@: Merging data from %@...", self, source); NSParameterAssert([[source nameOfClass] isEqualToString:self.nameOfClass]); [super mergeDataFromObject:source]; @@ -44,7 +44,7 @@ - (void)mergeDataFromObject:(id)source { if (![self nameOfSuperclass]) { self.nameOfSuperclass = sourceClass.nameOfSuperclass; } else if (sourceClass.nameOfSuperclass && ![self.nameOfSuperclass isEqualToString:sourceClass.nameOfSuperclass]) { - GBLogXWarn(self.prefferedSourceInfo, @"%@: Merged class's %@ superclass is different from current!", self, sourceClass); +// GBLogXWarn(self.prefferedSourceInfo, @"%@: Merged class's %@ superclass is different from current!", self, sourceClass); } // Forward merging request to components. diff --git a/Model/GBComment.h b/Model/GBComment.h index 819453da..5ae7fb80 100644 --- a/Model/GBComment.h +++ b/Model/GBComment.h @@ -7,8 +7,8 @@ // #import +#import "GBSourceInfo.h" -@class GBSourceInfo; @class GBCommentComponent; @class GBCommentComponentsList; diff --git a/Model/GBComment.m b/Model/GBComment.m index 645f072c..80ae5c52 100644 --- a/Model/GBComment.m +++ b/Model/GBComment.m @@ -8,6 +8,7 @@ #import "GBDataObjects.h" #import "GBComment.h" +#import "NSString+GBString.h" @implementation GBComment diff --git a/Model/GBCommentComponentsList.m b/Model/GBCommentComponentsList.m index 8956a41c..08ae052e 100644 --- a/Model/GBCommentComponentsList.m +++ b/Model/GBCommentComponentsList.m @@ -28,7 +28,7 @@ - (id)init { - (void)registerComponent:(id)component { NSParameterAssert(component != nil); - GBLogDebug(@"Registering component %@...", component); +// GBLogDebug(@"Registering component %@...", component); [_components addObject:component]; } diff --git a/Model/GBDocumentData.m b/Model/GBDocumentData.m index 9a47e840..3cc7b472 100644 --- a/Model/GBDocumentData.m +++ b/Model/GBDocumentData.m @@ -9,6 +9,7 @@ #import "GBApplicationSettingsProvider.h" #import "GBDataObjects.h" #import "GBDocumentData.h" +#import "NSString+GBString.h" @implementation GBDocumentData @@ -26,7 +27,7 @@ + (id)documentDataWithContents:(NSString *)contents path:(NSString *)path basePa - (id)initWithContents:(NSString *)contents path:(NSString *)path { NSParameterAssert(contents != nil); - GBLogDebug(@"Initializing document with contents %@...", [contents normalizedDescription]); +// GBLogDebug(@"Initializing document with contents %@...", [contents normalizedDescription]); self = [super init]; if (self) { GBSourceInfo *info = [GBSourceInfo infoWithFilename:path lineNumber:1]; diff --git a/Model/GBEnumConstantProvider.m b/Model/GBEnumConstantProvider.m index c256a3f2..166532e6 100644 --- a/Model/GBEnumConstantProvider.m +++ b/Model/GBEnumConstantProvider.m @@ -12,7 +12,7 @@ @implementation GBEnumConstantProvider - (id)initWithParentObject:(id)parent { NSParameterAssert(parent != nil); - GBLogDebug(@"Initializing enumConstant provider for %@...", parent); +// GBLogDebug(@"Initializing enumConstant provider for %@...", parent); self = [super init]; if (self) { _parent = parent; diff --git a/Model/GBIvarData.m b/Model/GBIvarData.m index fe52b0e1..8ee8328e 100644 --- a/Model/GBIvarData.m +++ b/Model/GBIvarData.m @@ -33,7 +33,7 @@ - (id)initWithDataFromComponents:(NSArray *)components { - (void)mergeDataFromObject:(id)source { if (!source || source == self) return; - GBLogDebug(@"%@: Merging data from %@...", self, source); +// GBLogDebug(@"%@: Merging data from %@...", self, source); NSParameterAssert([[source nameOfIvar] isEqualToString:self.nameOfIvar]); NSParameterAssert([[source ivarTypes] isEqualToArray:self.ivarTypes]); [super mergeDataFromObject:source]; diff --git a/Model/GBIvarsProvider.m b/Model/GBIvarsProvider.m index 6e738ad9..2e99fa38 100644 --- a/Model/GBIvarsProvider.m +++ b/Model/GBIvarsProvider.m @@ -15,7 +15,7 @@ @implementation GBIvarsProvider - (id)initWithParentObject:(id)parent { NSParameterAssert(parent != nil); - GBLogDebug(@"Initializing ivars provider for %@...", parent); +// GBLogDebug(@"Initializing ivars provider for %@...", parent); self = [super init]; if (self) { _parent = parent; @@ -29,7 +29,7 @@ - (id)initWithParentObject:(id)parent { - (void)registerIvar:(GBIvarData *)ivar { NSParameterAssert(ivar != nil); - GBLogDebug(@"%@: Registering ivar %@...", _parent, ivar); +// GBLogDebug(@"%@: Registering ivar %@...", _parent, ivar); if ([_ivars containsObject:ivar]) return; GBIvarData *existingIvar = _ivarsByName[ivar.nameOfIvar]; if (existingIvar) { @@ -43,7 +43,7 @@ - (void)registerIvar:(GBIvarData *)ivar { - (void)mergeDataFromIvarsProvider:(GBIvarsProvider *)source { if (!source || source == self) return; - GBLogDebug(@"%@: Merging ivars from %@...", _parent, source->_parent); +// GBLogDebug(@"%@: Merging ivars from %@...", _parent, source->_parent); for (GBIvarData *sourceIvar in source.ivars) { GBIvarData *existingIvar = _ivarsByName[sourceIvar.nameOfIvar]; if (existingIvar) { diff --git a/Model/GBMethodData.m b/Model/GBMethodData.m index 6a539e90..3d38e155 100644 --- a/Model/GBMethodData.m +++ b/Model/GBMethodData.m @@ -16,6 +16,7 @@ #import "GBStore.h" #import "GBApplicationSettingsProvider.h" +#import "NSException+GBException.h" @interface GBMethodData () @@ -378,17 +379,17 @@ - (BOOL)validateMergeWith:(GBMethodData *)source { - (void)mergeDataFromObject:(id)source { if (!source || source == self) return; - GBLogDebug(@"%@: Merging data from %@...", self, source); +// GBLogDebug(@"%@: Merging data from %@...", self, source); if (![self validateMergeWith:source]) return; // Use argument var names from the method that has comment. If no method has comment, just keep deafult. if ([source comment] && ![self comment]) { - GBLogDebug(@"%@: Checking for difference due to comment status...", self); +// GBLogDebug(@"%@: Checking for difference due to comment status...", self); for (NSUInteger i=0; i<[self.methodArguments count]; i++) { GBMethodArgument *ourArgument = [self methodArguments][i]; GBMethodArgument *otherArgument = [source methodArguments][i]; if (![ourArgument.argumentVar isEqualToString:otherArgument.argumentVar]) { - GBLogDebug(@"%@: Changing %ld. argument var name from %@ to %@...", self, i+1, ourArgument.argumentVar, otherArgument.argumentVar); +// GBLogDebug(@"%@: Changing %ld. argument var name from %@ to %@...", self, i+1, ourArgument.argumentVar, otherArgument.argumentVar); ourArgument.argumentVar = otherArgument.argumentVar; } } diff --git a/Model/GBMethodsProvider.m b/Model/GBMethodsProvider.m index 832deefc..ad95b1e3 100644 --- a/Model/GBMethodsProvider.m +++ b/Model/GBMethodsProvider.m @@ -26,7 +26,7 @@ @implementation GBMethodsProvider - (id)initWithParentObject:(id)parent { NSParameterAssert(parent != nil); - GBLogDebug(@"Initializing methods provider for %@...", parent); +// GBLogDebug(@"Initializing methods provider for %@...", parent); self = [super init]; if (self) { _parent = parent; @@ -45,7 +45,7 @@ - (id)initWithParentObject:(id)parent { #pragma mark Registration methods - (GBMethodSectionData *)registerSectionWithName:(NSString *)name { - GBLogDebug(@"%@: Registering section %@...", _parent, name ? name : @"default"); +// GBLogDebug(@"%@: Registering section %@...", _parent, name ? name : @"default"); GBMethodSectionData *section = [[GBMethodSectionData alloc] init]; section.sectionName = name; _registeringSection = section; @@ -63,7 +63,7 @@ - (GBMethodSectionData *)registerSectionIfNameIsValid:(NSString *)string { } - (void)unregisterEmptySections { - GBLogDebug(@"Unregistering empty sections..."); +// GBLogDebug(@"Unregistering empty sections..."); for (NSUInteger i=0; i<[_sections count]; i++) { GBMethodSectionData *section = _sections[i]; if ([section.methods count] == 0) { @@ -76,7 +76,7 @@ - (void)unregisterEmptySections { - (void)registerMethod:(GBMethodData *)method { // Note that we allow adding several methods with the same selector as long as the type is different (i.e. class and instance methods). In such case, methodBySelector will preffer instance method or property to class method! Note that this could be implemented more inteligently by prefixing selectors with some char or similar and then handling that within methodBySelector: and prefer instance/property in there. However at the time being current code seems sufficient and simpler, so let's stick with it for a while... NSParameterAssert(method != nil); - GBLogDebug(@"%@: Registering method %@...", _parent, method); +// GBLogDebug(@"%@: Registering method %@...", _parent, method); if ([_methods containsObject:method]) return; GBMethodData *existingMethod = _methodsBySelectors[method.methodSelector]; if (existingMethod && existingMethod.methodType == method.methodType) { @@ -170,7 +170,7 @@ - (BOOL)hasProperties { - (void)mergeDataFromMethodsProvider:(GBMethodsProvider *)source { // If a method with the same selector is found while merging from source, we should check if the type also matches. If so, we can merge the data from the source's method. However if the type doesn't match, we should ignore the method alltogether (ussually this is due to custom property implementation). We should probably deal with this scenario more inteligently, but it seems it works... if (!source || source == self) return; - GBLogDebug(@"%@: Merging methods from %@...", _parent, source->_parent); +// GBLogDebug(@"%@: Merging methods from %@...", _parent, source->_parent); // First merge all existing methods regardless of section and prepare the list of all new methods. NSMutableArray *newMethods = [NSMutableArray array]; diff --git a/Model/GBModelBase.m b/Model/GBModelBase.m index 305360e4..e8dd904b 100644 --- a/Model/GBModelBase.m +++ b/Model/GBModelBase.m @@ -48,7 +48,7 @@ - (void)mergeDataFromObject:(id)source { // Merge comment. GBComment *theComment = [(GBModelBase *)source comment]; if (self.comment && theComment) { - GBLogXInfo(self.prefferedSourceInfo, @"%@: Comment found in %@ and %@", self, self.comment.sourceInfo, theComment.sourceInfo); +// GBLogXInfo(self.prefferedSourceInfo, @"%@: Comment found in %@ and %@", self, self.comment.sourceInfo, theComment.sourceInfo); return; } if (!self.comment && theComment) self.comment = theComment; diff --git a/Model/GBProtocolData.m b/Model/GBProtocolData.m index 7ed9888a..f3473844 100644 --- a/Model/GBProtocolData.m +++ b/Model/GBProtocolData.m @@ -19,7 +19,7 @@ + (id)protocolDataWithName:(NSString *)name { - (id)initWithName:(NSString *)name { NSParameterAssert(name != nil && [name length] > 0); - GBLogDebug(@"Initializing protocol with name %@...", name); +// GBLogDebug(@"Initializing protocol with name %@...", name); self = [super init]; if (self) { _protocolName = [name copy]; @@ -33,7 +33,7 @@ - (id)initWithName:(NSString *)name { - (void)mergeDataFromObject:(id)source { if (!source || source == self) return; - GBLogDebug(@"%@: Merging data from %@...", self, source); +// GBLogDebug(@"%@: Merging data from %@...", self, source); NSParameterAssert([[source nameOfProtocol] isEqualToString:self.nameOfProtocol]); [super mergeDataFromObject:source]; GBProtocolData *sourceProtocol = (GBProtocolData *)source; diff --git a/Model/GBStore.m b/Model/GBStore.m index 4cfd0a0f..1350ed88 100644 --- a/Model/GBStore.m +++ b/Model/GBStore.m @@ -83,7 +83,7 @@ - (NSArray *)protocolsSortedByName { - (void)registerClass:(GBClassData *)class { NSParameterAssert(class != nil); - GBLogDebug(@"Registering class %@...", class); +// GBLogDebug(@"Registering class %@...", class); if ([_classes containsObject:class]) return; GBClassData *existingClass = _classesByName[class.nameOfClass]; if (existingClass) { @@ -96,7 +96,7 @@ - (void)registerClass:(GBClassData *)class { - (void)registerCategory:(GBCategoryData *)category { NSParameterAssert(category != nil); - GBLogDebug(@"Registering category %@...", category); +// GBLogDebug(@"Registering category %@...", category); if ([_categories containsObject:category]) return; NSString *categoryID = [NSString stringWithFormat:@"%@(%@)", category.nameOfClass, category.nameOfCategory ? category.nameOfCategory : @""]; GBCategoryData *existingCategory = _categoriesByName[categoryID]; @@ -110,7 +110,7 @@ - (void)registerCategory:(GBCategoryData *)category { - (void)registerProtocol:(GBProtocolData *)protocol { NSParameterAssert(protocol != nil); - GBLogDebug(@"Registering class %@...", protocol); +// GBLogDebug(@"Registering class %@...", protocol); if ([_protocols containsObject:protocol]) return; GBProtocolData *existingProtocol = _protocolsByName[protocol.nameOfProtocol]; if (existingProtocol) { @@ -124,11 +124,11 @@ - (void)registerProtocol:(GBProtocolData *)protocol { -(void)registerTypedefEnum:(GBTypedefEnumData *)typedefEnum { NSParameterAssert(typedefEnum != nil); - GBLogDebug(@"Registering typedef enum %@...", typedefEnum); +// GBLogDebug(@"Registering typedef enum %@...", typedefEnum); if ([_typedefEnums containsObject:typedefEnum]) return; GBProtocolData *existingTypedef = _typedefEnumsByName[typedefEnum.nameOfEnum]; if (existingTypedef) { - GBLogWarn(@"Ignoring typedef enum %@, already defined.", typedefEnum); +// GBLogWarn(@"Ignoring typedef enum %@, already defined.", typedefEnum); return; } @@ -139,11 +139,11 @@ -(void)registerTypedefEnum:(GBTypedefEnumData *)typedefEnum -(void)registerTypedefBlock:(GBTypedefBlockData *)typedefBlock { NSParameterAssert(typedefBlock != nil); - GBLogDebug(@"Registering typedef block %@...", typedefBlock); +// GBLogDebug(@"Registering typedef block %@...", typedefBlock); if ([_typedefBlocks containsObject:typedefBlock]) return; GBProtocolData *existingTypedef = _typedefBlocksByName[typedefBlock.nameOfBlock]; if (existingTypedef) { - GBLogWarn(@"Ignoring typedef block %@, already defined.", typedefBlock); +// GBLogWarn(@"Ignoring typedef block %@, already defined.", typedefBlock); return; } @@ -154,12 +154,12 @@ -(void)registerTypedefBlock:(GBTypedefBlockData *)typedefBlock - (void)registerDocument:(GBDocumentData *)document { NSParameterAssert(document != nil); - GBLogDebug(@"Registering document %@...", document); +// GBLogDebug(@"Registering document %@...", document); if ([_documents containsObject:document]) return; NSString *name = [document.nameOfDocument stringByDeletingPathExtension]; GBDocumentData *existingDocument = _documentsByName[name]; if (existingDocument) { - GBLogWarn(@"Ignoring document %@, already defined.", document); +// GBLogWarn(@"Ignoring document %@, already defined.", document); return; } @@ -170,7 +170,7 @@ - (void)registerDocument:(GBDocumentData *)document { - (void)registerCustomDocument:(GBDocumentData *)document withKey:(id)key { NSParameterAssert(document != nil); - GBLogDebug(@"Registering custom document %@...", document); +// GBLogDebug(@"Registering custom document %@...", document); [_customDocuments addObject:document]; _customDocumentsByKey[key] = document; } diff --git a/Parsing/GBObjectiveCParser.m b/Parsing/GBObjectiveCParser.m index 04ce877d..06ec2bcd 100644 --- a/Parsing/GBObjectiveCParser.m +++ b/Parsing/GBObjectiveCParser.m @@ -14,6 +14,7 @@ #import "GBApplicationSettingsProvider.h" #import "GBDataObjects.h" #import "GBObjectiveCParser.h" +#import "NSString+GBString.h" @interface GBObjectiveCParser () @@ -79,7 +80,7 @@ + (id)parserWithSettingsProvider:(id)settingsProvider { - (id)initWithSettingsProvider:(id)settingsProvider { NSParameterAssert(settingsProvider != nil); - GBLogDebug(@"Initializing objective-c parser with settings provider %@...", settingsProvider); +// GBLogDebug(@"Initializing objective-c parser with settings provider %@...", settingsProvider); self = [super init]; if (self) { self.settings = settingsProvider; @@ -94,7 +95,7 @@ - (void)parseObjectsFromString:(NSString *)input sourceFile:(NSString *)filename NSParameterAssert(filename != nil); NSParameterAssert([filename length] > 0); NSParameterAssert(aStore != nil); - GBLogDebug(@"Parsing objective-c objects..."); +// GBLogDebug(@"Parsing objective-c objects..."); self.store = aStore; self.tokenizer = [GBTokenizer tokenizerWithSource:[self tokenizerWithInputString:input] filename:filename settings:self.settings]; self.includeInOutput = YES; @@ -157,7 +158,7 @@ - (void)matchClassDefinition { GBClassData *class = [GBClassData classDataWithName:className]; class.includeInOutput = self.includeInOutput; [self registerSourceInfoFromCurrentTokenToObject:class]; - GBLogDebug(@"Matched %@ class definition at line %lu.", className, class.prefferedSourceInfo.lineNumber); +// GBLogDebug(@"Matched %@ class definition at line %lu.", className, class.prefferedSourceInfo.lineNumber); [self registerLastCommentToObject:class]; [self.tokenizer consume:2]; [self matchSuperclassForClass:class]; @@ -178,7 +179,7 @@ - (void)matchCategoryDefinition { GBCategoryData *category = [GBCategoryData categoryDataWithName:categoryName className:className]; category.includeInOutput = self.includeInOutput; [self registerSourceInfoFromCurrentTokenToObject:category]; - GBLogVerbose(@"Matched %@(%@) category definition at line %lu.", className, categoryName, category.prefferedSourceInfo.lineNumber); +// GBLogVerbose(@"Matched %@(%@) category definition at line %lu.", className, categoryName, category.prefferedSourceInfo.lineNumber); [self registerLastCommentToObject:category]; [self.tokenizer consume:5]; [self matchAdoptedProtocolForProvider:category.adoptedProtocols]; @@ -195,7 +196,7 @@ - (void)matchExtensionDefinition { NSString *className = [[self.tokenizer lookahead:1] stringValue]; GBCategoryData *extension = [GBCategoryData categoryDataWithName:nil className:className]; extension.includeInOutput = self.includeInOutput; - GBLogVerbose(@"Matched %@() extension definition at line %lu.", className, extension.prefferedSourceInfo.lineNumber); +// GBLogVerbose(@"Matched %@() extension definition at line %lu.", className, extension.prefferedSourceInfo.lineNumber); [self registerSourceInfoFromCurrentTokenToObject:extension]; [self registerLastCommentToObject:extension]; [self.tokenizer consume:4]; @@ -213,7 +214,7 @@ - (void)matchProtocolDefinition { NSString *protocolName = [[self.tokenizer lookahead:1] stringValue]; GBProtocolData *protocol = [GBProtocolData protocolDataWithName:protocolName]; protocol.includeInOutput = self.includeInOutput; - GBLogVerbose(@"Matched %@ protocol definition at line %lu.", protocolName, protocol.prefferedSourceInfo.lineNumber); +// GBLogVerbose(@"Matched %@ protocol definition at line %lu.", protocolName, protocol.prefferedSourceInfo.lineNumber); [self registerSourceInfoFromCurrentTokenToObject:protocol]; [self registerLastCommentToObject:protocol]; [self.tokenizer consume:2]; @@ -229,7 +230,7 @@ - (void)matchProtocolDefinition { - (void)matchSuperclassForClass:(GBClassData *)class { if (![[self.tokenizer currentToken] matches:@":"]) return; class.nameOfSuperclass = [[self.tokenizer lookahead:1] stringValue]; - GBLogDebug(@"Matched superclass %@.", class.nameOfSuperclass); +// GBLogDebug(@"Matched superclass %@.", class.nameOfSuperclass); [self.tokenizer consume:2]; } @@ -237,7 +238,7 @@ - (void)matchAdoptedProtocolForProvider:(GBAdoptedProtocolsProvider *)provider { [self.tokenizer consumeFrom:@"<" to:@">" usingBlock:^(PKToken *token, BOOL *consume, BOOL *stop) { if ([token matches:@","]) return; GBProtocolData *protocol = [[GBProtocolData alloc] initWithName:[token stringValue]]; - GBLogDebug(@"Matched adopted protocol %@.", protocol); +// GBLogDebug(@"Matched adopted protocol %@.", protocol); [provider registerProtocol:protocol]; }]; } @@ -318,7 +319,7 @@ - (BOOL)matchPropertyDefinitionForProvider:(GBMethodsProvider *)provider require // Register property. GBMethodData *propertyData = [GBMethodData propertyDataWithAttributes:propertyAttributes components:propertyComponents]; [propertyData registerSourceInfo:filedata]; - GBLogDebug(@"Matched property definition %@ at line %lu.", propertyData, propertyData.prefferedSourceInfo.lineNumber); +// GBLogDebug(@"Matched property definition %@ at line %lu.", propertyData, propertyData.prefferedSourceInfo.lineNumber); [self registerComment:comment toObject:propertyData startingWith:startToken]; [propertyData setIsRequired:required]; [provider registerSectionIfNameIsValid:sectionName]; @@ -342,7 +343,7 @@ - (void)matchClassDeclaration { GBClassData *class = [GBClassData classDataWithName:className]; class.includeInOutput = self.includeInOutput; [self registerSourceInfoFromCurrentTokenToObject:class]; - GBLogVerbose(@"Matched %@ class declaration at line %lu.", className, class.prefferedSourceInfo.lineNumber); +// GBLogVerbose(@"Matched %@ class declaration at line %lu.", className, class.prefferedSourceInfo.lineNumber); [self registerLastCommentToObject:class]; [self.tokenizer consume:2]; @@ -360,7 +361,7 @@ - (void)matchCategoryDeclaration { GBCategoryData *category = [GBCategoryData categoryDataWithName:categoryName className:className]; category.includeInOutput = self.includeInOutput; [self registerSourceInfoFromCurrentTokenToObject:category]; - GBLogVerbose(@"Matched %@(%@) category declaration at line %lu.", className, categoryName, category.prefferedSourceInfo.lineNumber); +// GBLogVerbose(@"Matched %@(%@) category declaration at line %lu.", className, categoryName, category.prefferedSourceInfo.lineNumber); [self registerLastCommentToObject:category]; [self.tokenizer consume:5]; @@ -480,7 +481,7 @@ - (BOOL)matchTypedefBlockDefinitionForProvider { GBSourceInfo *startInfo = [tokenizer sourceInfoForCurrentToken]; GBComment *lastComment = [tokenizer lastComment]; - GBLogVerbose(@"Matched %@ typedef block definition at line %lu.", blockName, startInfo.lineNumber); +// GBLogVerbose(@"Matched %@ typedef block definition at line %lu.", blockName, startInfo.lineNumber); [self.tokenizer consume:2]; @@ -597,7 +598,7 @@ - (BOOL)matchTypedefEnumDefinition { GBSourceInfo *startInfo = [tokenizer sourceInfoForCurrentToken]; GBComment *lastComment = [tokenizer lastComment]; - GBLogVerbose(@"Matched %@ typedef enum definition at line %lu.", typedefName, startInfo.lineNumber); +// GBLogVerbose(@"Matched %@ typedef enum definition at line %lu.", typedefName, startInfo.lineNumber); GBTypedefEnumData *newEnum = [GBTypedefEnumData typedefEnumWithName:typedefName]; newEnum.includeInOutput = self.includeInOutput; @@ -676,8 +677,8 @@ - (BOOL)matchTypedefEnumDefinition { if(isRegularEnum && isCurlyBrace && self.settings.warnOnUnsupportedTypedefEnum) { - GBSourceInfo *startInfo = [tokenizer sourceInfoForCurrentToken]; - GBLogXWarn(startInfo, @"unsupported typedef enum at %@!", startInfo); +// GBSourceInfo *startInfo = [tokenizer sourceInfoForCurrentToken]; +// GBLogXWarn(startInfo, @"unsupported typedef enum at %@!", startInfo); } } return NO; @@ -911,7 +912,7 @@ - (BOOL)matchMethodDataForProvider:(GBMethodsProvider *)provider from:(NSString // Create method instance and register it. GBMethodData *methodData = [GBMethodData methodDataWithType:methodType result:methodResult arguments:methodArgs]; [methodData registerSourceInfo:filedata]; - GBLogDebug(@"Matched method %@%@ at line %lu.", start, methodData, methodData.prefferedSourceInfo.lineNumber); +// GBLogDebug(@"Matched method %@%@ at line %lu.", start, methodData, methodData.prefferedSourceInfo.lineNumber); [self registerComment:comment toObject:methodData startingWith:startToken]; [methodData setIsRequired:required]; [provider registerSectionIfNameIsValid:sectionName]; @@ -932,21 +933,21 @@ - (void)registerComment:(GBComment *)comment toObject:(GBModelBase *)object star if (startToken) { GBComment *postfixComment = [self.tokenizer postfixCommentFrom:startToken]; if (comment && postfixComment) { - GBLogInfo(@"Ignored postfix comment '%@' from '%@' in favour of '%@'", - [postfixComment.stringValue normalizedDescription], - object, - [comment.stringValue normalizedDescription]); +// GBLogInfo(@"Ignored postfix comment '%@' from '%@' in favour of '%@'", +// [postfixComment.stringValue normalizedDescription], +// object, +// [comment.stringValue normalizedDescription]); } if (!comment && postfixComment) { - GBLogDebug(@"Using postfix comment '%@' for '%@'", - [postfixComment.stringValue normalizedDescription], - object); +// GBLogDebug(@"Using postfix comment '%@' for '%@'", +// [postfixComment.stringValue normalizedDescription], +// object); comment = postfixComment; } } [object setComment:comment]; - if (comment) GBLogDebug(@"Assigned comment '%@' to '%@'...", [comment.stringValue normalizedDescription], object); +// if (comment) GBLogDebug(@"Assigned comment '%@' to '%@'...", [comment.stringValue normalizedDescription], object); } - (void)registerSourceInfoFromCurrentTokenToObject:(GBModelBase *)object { diff --git a/Parsing/GBParser.m b/Parsing/GBParser.m index d12250f3..fc6aa184 100644 --- a/Parsing/GBParser.m +++ b/Parsing/GBParser.m @@ -11,6 +11,8 @@ #import "GBApplicationSettingsProvider.h" #import "GBObjectiveCParser.h" #import "GBParser.h" +#import "NSObject+GBObject.h" +#import "NSFileManager+GBFileManager.h" @interface GBParser () @@ -42,7 +44,7 @@ + (id)parserWithSettingsProvider:(id)settingsProvider { - (id)initWithSettingsProvider:(id)settingsProvider { NSParameterAssert(settingsProvider != nil); - GBLogDebug(@"Initializing parser with settings provider %@...", settingsProvider); +// GBLogDebug(@"Initializing parser with settings provider %@...", settingsProvider); self = [super init]; if (self) { self.settings = settingsProvider; @@ -56,14 +58,14 @@ - (id)initWithSettingsProvider:(id)settingsProvider { - (void)parseObjectsFromPaths:(NSArray *)paths toStore:(id)aStore { NSParameterAssert(paths != nil); NSParameterAssert(aStore != nil); - GBLogVerbose(@"Parsing objects from %lu paths...", [paths count]); +// GBLogVerbose(@"Parsing objects from %lu paths...", [paths count]); self.store = aStore; self.numberOfParsedFiles = 0; for (NSString *input in paths) { [self parsePath:input usingBlock:^(NSString *path) { if (![self isSourceCodeFile:path]) return; - GBLogInfo(@"Parsing source code from '%@'...", path); +// GBLogInfo(@"Parsing source code from '%@'...", path); NSError *error = nil; NSString *contents = nil; NSArray *encodings = @[@(NSUTF8StringEncoding), @(NSISOLatin1StringEncoding)]; @@ -73,7 +75,7 @@ - (void)parseObjectsFromPaths:(NSArray *)paths toStore:(id)aStore { if (!error) break; } if (error) { - GBLogNSError(error, @"Failed reading contents of source file '%@'!", path); +// GBLogNSError(error, @"Failed reading contents of source file '%@'!", path); return; } @@ -81,27 +83,27 @@ - (void)parseObjectsFromPaths:(NSArray *)paths toStore:(id)aStore { self.numberOfParsedFiles++; }]; } - GBLogVerbose(@"Parsed %lu source files.", self.numberOfParsedFiles); +// GBLogVerbose(@"Parsed %lu source files.", self.numberOfParsedFiles); } - (void)parseDocumentsFromPaths:(NSArray *)paths toStore:(id)aStore { NSParameterAssert(paths != nil); NSParameterAssert(aStore != nil); - GBLogVerbose(@"Parsing static documents from %lu paths...", (unsigned long) [paths count]); +// GBLogVerbose(@"Parsing static documents from %lu paths...", (unsigned long) [paths count]); self.store = aStore; self.numberOfParsedDocuments = 0; for (NSString *input in paths) { [self parsePath:input usingBlock:^(NSString *path) { if (![self isDocumentFile:path]) return; - GBLogInfo(@"Parsing static document from '%@'...", path); +// GBLogInfo(@"Parsing static document from '%@'...", path); NSError *error = nil; NSString *contents = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error]; if (error) { - GBLogNSError(error, @"Failed reading contents of static document '%@'...", path); +// GBLogNSError(error, @"Failed reading contents of static document '%@'...", path); return; } - if ([contents length] == 0) GBLogWarn(@"Empty static document found at '%@'!", path); +// if ([contents length] == 0) GBLogWarn(@"Empty static document found at '%@'!", path); GBDocumentData *document = [GBDocumentData documentDataWithContents:contents path:path]; document.basePathOfDocument = [input stringByStandardizingPath]; @@ -110,7 +112,7 @@ - (void)parseDocumentsFromPaths:(NSArray *)paths toStore:(id)aStore { self.numberOfParsedDocuments++; }]; } - GBLogVerbose(@"Parsed %lu static document files.", self.numberOfParsedDocuments); +// GBLogVerbose(@"Parsed %lu static document files.", self.numberOfParsedDocuments); } - (void)parseCustomDocumentFromPath:(NSString *)path outputSubpath:(NSString *)subpath key:(id)key toStore:(id)aStore { @@ -118,16 +120,16 @@ - (void)parseCustomDocumentFromPath:(NSString *)path outputSubpath:(NSString *)s NSParameterAssert(key != nil); NSParameterAssert(aStore != nil); self.store = aStore; - GBLogInfo(@"Parsing custom document from '%@'...", path); +// GBLogInfo(@"Parsing custom document from '%@'...", path); NSError *error = nil; NSString *contents = [NSString stringWithContentsOfFile:[path stringByStandardizingPath] encoding:NSUTF8StringEncoding error:&error]; if (error) { - GBLogNSError(error, @"Failed reading contents of custom document '%@'...", path); +// GBLogNSError(error, @"Failed reading contents of custom document '%@'...", path); return; } if ([contents length] == 0) { - GBLogWarn(@"Empty custom document found at '%@'!", path); +// GBLogWarn(@"Empty custom document found at '%@'!", path); return; } @@ -140,7 +142,7 @@ - (void)parseCustomDocumentFromPath:(NSString *)path outputSubpath:(NSString *)s #pragma mark Parsing helpers - (void)parsePath:(NSString *)input usingBlock:(void (^)(NSString *path))block { - GBLogDebug(@"Parsing '%@'...", input); +// GBLogDebug(@"Parsing '%@'...", input); NSString *standardized = [input stringByStandardizingPath]; if ([self.fileManager isPathDirectory:[standardized stringByStandardizingPath]]) [self parseDirectory:standardized usingBlock:block]; @@ -149,11 +151,11 @@ - (void)parsePath:(NSString *)input usingBlock:(void (^)(NSString *path))block { } - (void)parseDirectory:(NSString *)input usingBlock:(void (^)(NSString *path))block { - GBLogDebug(@"Parsing path '%@'...", input); +// GBLogDebug(@"Parsing path '%@'...", input); // Skip directory if found in --ignore paths. if ([self isPathIgnored:input]) { - GBLogNormal(@"Ignoring path '%@'...", input); +// GBLogNormal(@"Ignoring path '%@'...", input); return; } @@ -161,7 +163,7 @@ - (void)parseDirectory:(NSString *)input usingBlock:(void (^)(NSString *path))bl NSError *error = nil; NSArray *contents = [self.fileManager contentsOfDirectoryAtPath:input error:&error]; if (error) { - GBLogNSError(error, @"Failed fetching contents of '%@'!", input); +// GBLogNSError(error, @"Failed fetching contents of '%@'!", input); return; } @@ -183,11 +185,11 @@ - (void)parseDirectory:(NSString *)input usingBlock:(void (^)(NSString *path))bl } - (void)parseFile:(NSString *)input usingBlock:(void (^)(NSString *path))block { - GBLogDebug(@"Parsing file '%@'...", input); +// GBLogDebug(@"Parsing file '%@'...", input); // Skip file if found in --ignore paths. if ([self isPathIgnored:input]) { - GBLogNormal(@"Ignoring file '%@'...", input); +// GBLogNormal(@"Ignoring file '%@'...", input); return; } diff --git a/Parsing/GBTokenizer.h b/Parsing/GBTokenizer.h index 917f05b0..44f1c80f 100644 --- a/Parsing/GBTokenizer.h +++ b/Parsing/GBTokenizer.h @@ -9,8 +9,10 @@ #import #import +#import "GBComment.h" + @class GBSourceInfo; -@class GBComment; +//@class GBComment; /** Provides common methods for tokenizing input source strings. diff --git a/Parsing/GBTokenizer.m b/Parsing/GBTokenizer.m index 1b296feb..dbe54512 100644 --- a/Parsing/GBTokenizer.m +++ b/Parsing/GBTokenizer.m @@ -12,6 +12,7 @@ #import "GBSourceInfo.h" #import "GBComment.h" #import "GBTokenizer.h" +#import "NSString+GBString.h" @interface GBTokenizer () @@ -58,7 +59,7 @@ - (id)initWithSourceTokenizer:(PKTokenizer *)tokenizer filename:(NSString *)aFil NSParameterAssert(tokenizer != nil); NSParameterAssert(aFilename != nil); NSParameterAssert([aFilename length] > 0); - GBLogDebug(@"Initializing tokenizer..."); +// GBLogDebug(@"Initializing tokenizer..."); self = [super init]; if (self) { self.settings = theSettings; @@ -410,7 +411,7 @@ - (NSArray *)linesByReorderingHeaderDocDirectives:(NSArray *)lines { } - (void)resetComments { - GBLogDebug(@"Resetting comments..."); +// GBLogDebug(@"Resetting comments..."); [self.lastCommentBuilder setString:@""]; [self.previousCommentBuilder setString:@""]; } diff --git a/Podfile b/Podfile index 119f796a..47c5059c 100644 --- a/Podfile +++ b/Podfile @@ -7,20 +7,14 @@ def default_pods # Discount '2.1.5a' with configure and make pod 'Discount', :podspec => 'Specs/Discount.podspec' pod 'GRMustache', '~> 7.0.2' - pod 'Minizip/minishared', :git => 'https://github.com/nmoinvaz/minizip.git' - pod 'DDMinizip', :podspec => 'Specs/DDMinizip.podspec' -end - -def tests_pods - pod 'GHUnit', '~> 0.5' - pod 'OCMock', '~> 3.4' + pod 'CocoaLumberjack' end target 'appledoc' do default_pods end -target 'AppledocTests' do +target 'appledocTests' do default_pods - tests_pods + pod 'OCMock', '~> 3.4' end diff --git a/Podfile.lock b/Podfile.lock index e86c6852..3bc71ac2 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,62 +1,55 @@ PODS: - - DDMinizip (1.0.0.2017.06.25) + - CocoaLumberjack (1.9.1): + - CocoaLumberjack/Extensions (= 1.9.1) + - CocoaLumberjack/Core (1.9.1) + - CocoaLumberjack/Extensions (1.9.1): + - CocoaLumberjack/Core - Discount (2.1.5a) - - GHUnit (0.5.8) - GRMustache (7.0.2): - JRSwizzle (~> 1.0) - JRSwizzle (1.0) - - Minizip/Core (1.1.0.2017.06.25) - - Minizip/minishared (1.1.0.2017.06.25): - - Minizip/Core - - OCMock (3.4) + - OCMock (3.4.2) - ParseKit (0.0.0.2010.4.29): - RegexKitLite (~> 4.0.1) - RegexKitLite (4.0.6) DEPENDENCIES: - - DDMinizip (from `Specs/DDMinizip.podspec`) + - CocoaLumberjack - Discount (from `Specs/Discount.podspec`) - - GHUnit (~> 0.5) - GRMustache (~> 7.0.2) - - Minizip/minishared (from `https://github.com/nmoinvaz/minizip.git`) - OCMock (~> 3.4) - ParseKit (from `Specs/ParseKit.podspec`) - RegexKitLite (from `https://github.com/inquisitiveSoft/RegexKitLite.git`) +SPEC REPOS: + trunk: + - CocoaLumberjack + - GRMustache + - JRSwizzle + - OCMock + EXTERNAL SOURCES: - DDMinizip: - :podspec: Specs/DDMinizip.podspec Discount: :podspec: Specs/Discount.podspec - Minizip: - :git: https://github.com/nmoinvaz/minizip.git ParseKit: :podspec: Specs/ParseKit.podspec RegexKitLite: :git: https://github.com/inquisitiveSoft/RegexKitLite.git CHECKOUT OPTIONS: - DDMinizip: - :commit: 433d3c974191e76ba42dc9166d77bd77ef589c2d - :git: https://github.com/Daij-Djan/DDMinizip.git - Minizip: - :commit: c6d04f9c642a730a4d5a295b811ec884b4fe3ba2 - :git: https://github.com/nmoinvaz/minizip.git RegexKitLite: :commit: 871fad38339785248c51ebe5ee8403f7e75d51c4 :git: https://github.com/inquisitiveSoft/RegexKitLite.git SPEC CHECKSUMS: - DDMinizip: 83ed28588afe79b164907317610e3862ad494d75 + CocoaLumberjack: e9b828e64142be63c1c130517b33aa5e235d2413 Discount: 2a100efef8ec69e3c59a9ab5a20cdec3d179e93c - GHUnit: 07609b0386af75f20ce520277d1c24fd8cd1598e GRMustache: a724bfb0ac23c8f88a6388df9c7d73bc26e7005c JRSwizzle: dd5ead5d913a0f29e7f558200165849f006bb1e3 - Minizip: b7213b5711d7c8961326f15f6c22fc9947950dd8 - OCMock: 35ae71d6a8fcc1b59434d561d1520b9dd4f15765 + OCMock: ebe9ee1dca7fbed0ff9193ac0b3e2d8862ea56f6 ParseKit: 92f20b0017e23dd3c418e648169a13b8aa26bc24 RegexKitLite: 185a6b9d126b14e3e1f4df7570a50a3b3e27a036 -PODFILE CHECKSUM: 504b2e21b6ab7feca9cc228effa83eacae7055bb +PODFILE CHECKSUM: f44a670774a47c345a0ee6e6c7d36dddcc706c80 -COCOAPODS: 1.3.0.beta.2 +COCOAPODS: 1.8.4 diff --git a/Pods/CocoaLumberjack/LICENSE.txt b/Pods/CocoaLumberjack/LICENSE.txt new file mode 100644 index 00000000..66a942c2 --- /dev/null +++ b/Pods/CocoaLumberjack/LICENSE.txt @@ -0,0 +1,18 @@ +Software License Agreement (BSD License) + +Copyright (c) 2010, Deusty, LLC +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + +* Neither the name of Deusty nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior + written permission of Deusty, LLC. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/Pods/CocoaLumberjack/Lumberjack/DDASLLogCapture.h b/Pods/CocoaLumberjack/Lumberjack/DDASLLogCapture.h new file mode 100644 index 00000000..53dc6b0c --- /dev/null +++ b/Pods/CocoaLumberjack/Lumberjack/DDASLLogCapture.h @@ -0,0 +1,23 @@ +// +// DDASLLogCapture.h +// Lumberjack +// +// Created by Dario Ahdoot on 3/17/14. +// +// + +#import "DDASLLogger.h" + +@protocol DDLogger; + +@interface DDASLLogCapture : NSObject + ++ (void)start; ++ (void)stop; + +// Default log level: LOG_LEVEL_VERBOSE (i.e. capture all ASL messages). ++ (int)captureLogLevel; ++ (void)setCaptureLogLevel:(int)LOG_LEVEL_XXX; + +@end + diff --git a/Pods/CocoaLumberjack/Lumberjack/DDASLLogCapture.m b/Pods/CocoaLumberjack/Lumberjack/DDASLLogCapture.m new file mode 100644 index 00000000..36890cbb --- /dev/null +++ b/Pods/CocoaLumberjack/Lumberjack/DDASLLogCapture.m @@ -0,0 +1,180 @@ +// +// DDASLLogCapture.m +// Lumberjack +// +// Created by Dario Ahdoot on 3/17/14. +// +// + +#import "DDASLLogCapture.h" +#import "DDLog.h" + +#include +#include +#include +#include + +static BOOL _cancel = YES; +static int _captureLogLevel = LOG_LEVEL_VERBOSE; + +@implementation DDASLLogCapture + ++ (void)start +{ + // Ignore subsequent calls + if (!_cancel) + return; + + _cancel = NO; + + dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) + { + [DDASLLogCapture captureAslLogs]; + }); +} + ++ (void)stop +{ + _cancel = YES; +} + ++ (int)captureLogLevel +{ + return _captureLogLevel; +} + ++ (void)setCaptureLogLevel:(int)LOG_LEVEL_XXX +{ + _captureLogLevel = LOG_LEVEL_XXX; +} + +# pragma mark - Private methods + ++ (void)configureAslQuery:(aslmsg)query +{ + const char param[] = "7"; // ASL_LEVEL_DEBUG, which is everything. We'll rely on regular DDlog log level to filter + asl_set_query(query, ASL_KEY_LEVEL, param, ASL_QUERY_OP_LESS_EQUAL | ASL_QUERY_OP_NUMERIC); + +#if !TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR + int processId = [[NSProcessInfo processInfo] processIdentifier]; + char pid[16]; + sprintf(pid, "%d", processId); + asl_set_query(query, ASL_KEY_PID, pid, ASL_QUERY_OP_EQUAL | ASL_QUERY_OP_NUMERIC); +#endif +} + ++ (void)aslMessageRecieved:(aslmsg)msg +{ + // NSString * sender = [NSString stringWithCString:asl_get(msg, ASL_KEY_SENDER) encoding:NSUTF8StringEncoding]; + NSString * message = [NSString stringWithCString:asl_get(msg, ASL_KEY_MSG) encoding:NSUTF8StringEncoding]; + NSString * level = [NSString stringWithCString:asl_get(msg, ASL_KEY_LEVEL) encoding:NSUTF8StringEncoding]; + NSString * secondsStr = [NSString stringWithCString:asl_get(msg, ASL_KEY_TIME) encoding:NSUTF8StringEncoding]; + NSString * nanoStr = [NSString stringWithCString:asl_get(msg, ASL_KEY_TIME_NSEC) encoding:NSUTF8StringEncoding]; + + NSTimeInterval seconds = [secondsStr doubleValue]; + NSTimeInterval nanoSeconds = [nanoStr doubleValue]; + NSTimeInterval totalSeconds = seconds + (nanoSeconds / 1e9); + + NSDate * timeStamp = [NSDate dateWithTimeIntervalSince1970:totalSeconds]; + + int flag; + BOOL async; + switch([level intValue]) + { + // By default all NSLog's with a ASL_LEVEL_WARNING level + case ASL_LEVEL_EMERG : + case ASL_LEVEL_ALERT : + case ASL_LEVEL_CRIT : flag = LOG_FLAG_ERROR; async = LOG_ASYNC_ERROR; break; + case ASL_LEVEL_ERR : flag = LOG_FLAG_WARN; async = LOG_ASYNC_WARN; break; + case ASL_LEVEL_WARNING : flag = LOG_FLAG_INFO; async = LOG_ASYNC_INFO; break; + case ASL_LEVEL_NOTICE : flag = LOG_FLAG_DEBUG; async = LOG_ASYNC_DEBUG; break; + case ASL_LEVEL_INFO : + case ASL_LEVEL_DEBUG : + default : flag = LOG_FLAG_VERBOSE; async = LOG_ASYNC_VERBOSE; break; + } + + if (!(_captureLogLevel & flag)) + return; + + DDLogMessage * logMessage = [[DDLogMessage alloc]initWithLogMsg:message + level:_captureLogLevel + flag:flag + context:0 + file:"DDASLLogCapture" + function:0 + line:0 + tag:nil + options:0 + timestamp:timeStamp]; + + [DDLog log:async message:logMessage]; +} + ++ (void)captureAslLogs +{ + @autoreleasepool + { + /* + We use ASL_KEY_MSG_ID to see each message once, but there's no + obvious way to get the "next" ID. To bootstrap the process, we'll + search by timestamp until we've seen a message. + */ + + struct timeval timeval = { .tv_sec = 0 }; + gettimeofday(&timeval, NULL); + unsigned long long startTime = timeval.tv_sec; + __block unsigned long long lastSeenID = 0; + + /* + syslogd posts kNotifyASLDBUpdate (com.apple.system.logger.message) + through the notify API when it saves messages to the ASL database. + There is some coalescing - currently it is sent at most twice per + second - but there is no documented guarantee about this. In any + case, there may be multiple messages per notification. + + Notify notifications don't carry any payload, so we need to search + for the messages. + */ + int notifyToken = 0; // Can be used to unregister with notify_cancel(). + notify_register_dispatch(kNotifyASLDBUpdate, ¬ifyToken, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^(int token) + { + // At least one message has been posted; build a search query. + @autoreleasepool + { + aslmsg query = asl_new(ASL_TYPE_QUERY); + char stringValue[64]; + if (lastSeenID > 0) + { + snprintf(stringValue, sizeof stringValue, "%llu", lastSeenID); + asl_set_query(query, ASL_KEY_MSG_ID, stringValue, ASL_QUERY_OP_GREATER | ASL_QUERY_OP_NUMERIC); + } + else + { + snprintf(stringValue, sizeof stringValue, "%llu", startTime); + asl_set_query(query, ASL_KEY_TIME, stringValue, ASL_QUERY_OP_GREATER_EQUAL | ASL_QUERY_OP_NUMERIC); + } + [DDASLLogCapture configureAslQuery:query]; + + // Iterate over new messages. + aslmsg msg; + aslresponse response = asl_search(NULL, query); + while ((msg = aslresponse_next(response))) + { + [DDASLLogCapture aslMessageRecieved:msg]; + + // Keep track of which messages we've seen. + lastSeenID = atoll(asl_get(msg, ASL_KEY_MSG_ID)); + } + aslresponse_free(response); + + if(_cancel) + { + notify_cancel(notifyToken); + return; + } + } + }); + } +} + +@end \ No newline at end of file diff --git a/Common/ThirdParty/CocoaLumberjack/DDASLLogger.h b/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h similarity index 76% rename from Common/ThirdParty/CocoaLumberjack/DDASLLogger.h rename to Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h index eec4bb2a..a55eb6fe 100755 --- a/Common/ThirdParty/CocoaLumberjack/DDASLLogger.h +++ b/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h @@ -1,16 +1,15 @@ #import -#import #import "DDLog.h" /** * Welcome to Cocoa Lumberjack! * - * The Google Code page has a wealth of documentation if you have any questions. - * http://code.google.com/p/cocoalumberjack/ + * The project page has a wealth of documentation if you have any questions. + * https://github.com/CocoaLumberjack/CocoaLumberjack * - * If you're new to the project you may wish to read the "Getting Started" page. - * http://code.google.com/p/cocoalumberjack/wiki/GettingStarted + * If you're new to the project you may wish to read the "Getting Started" wiki. + * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted * * * This class provides a logger for the Apple System Log facility. @@ -27,11 +26,8 @@ **/ @interface DDASLLogger : DDAbstractLogger -{ - aslclient client; -} -+ (DDASLLogger *)sharedInstance; ++ (instancetype)sharedInstance; // Inherited from DDAbstractLogger diff --git a/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m b/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m new file mode 100755 index 00000000..020acb23 --- /dev/null +++ b/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m @@ -0,0 +1,95 @@ +#import "DDASLLogger.h" +#import +#import + +/** + * Welcome to Cocoa Lumberjack! + * + * The project page has a wealth of documentation if you have any questions. + * https://github.com/CocoaLumberjack/CocoaLumberjack + * + * If you're new to the project you may wish to read the "Getting Started" wiki. + * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted +**/ + +#if ! __has_feature(objc_arc) +#error This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC). +#endif + +static DDASLLogger *sharedInstance; + +@implementation DDASLLogger +{ + aslclient client; +} + ++ (instancetype)sharedInstance +{ + static dispatch_once_t DDASLLoggerOnceToken; + dispatch_once(&DDASLLoggerOnceToken, ^{ + sharedInstance = [[[self class] alloc] init]; + }); + + return sharedInstance; +} + +- (id)init +{ + if (sharedInstance != nil) + { + return nil; + } + + if ((self = [super init])) + { + // A default asl client is provided for the main thread, + // but background threads need to create their own client. + + client = asl_open(NULL, "com.apple.console", 0); + } + return self; +} + +- (void)logMessage:(DDLogMessage *)logMessage +{ + // Skip captured log messages. + if (strcmp(logMessage->file, "DDASLLogCapture") == 0) + return; + + NSString *logMsg = logMessage->logMsg; + + if (formatter) + { + logMsg = [formatter formatLogMessage:logMessage]; + } + + if (logMsg) + { + const char *msg = [logMsg UTF8String]; + + int aslLogLevel; + switch (logMessage->logFlag) + { + // Note: By default ASL will filter anything above level 5 (Notice). + // So our mappings shouldn't go above that level. + case LOG_FLAG_ERROR : aslLogLevel = ASL_LEVEL_CRIT; break; + case LOG_FLAG_WARN : aslLogLevel = ASL_LEVEL_ERR; break; + case LOG_FLAG_INFO : aslLogLevel = ASL_LEVEL_WARNING; break; // Regular NSLog's level + case LOG_FLAG_DEBUG : + case LOG_FLAG_VERBOSE : + default : aslLogLevel = ASL_LEVEL_NOTICE; break; + } + + aslmsg m = asl_new(ASL_TYPE_MSG); + asl_set(m, ASL_KEY_READ_UID, "501"); + asl_log(client, m, aslLogLevel, "%s", msg); + asl_free(m); + } +} + +- (NSString *)loggerName +{ + return @"cocoa.lumberjack.aslLogger"; +} + +@end diff --git a/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h b/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h new file mode 100644 index 00000000..4e0c33cd --- /dev/null +++ b/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h @@ -0,0 +1,102 @@ +#import + +#import "DDLog.h" + +/** + * Welcome to Cocoa Lumberjack! + * + * The project page has a wealth of documentation if you have any questions. + * https://github.com/CocoaLumberjack/CocoaLumberjack + * + * If you're new to the project you may wish to read the "Getting Started" wiki. + * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted + * + * + * This class provides an abstract implementation of a database logger. + * + * That is, it provides the base implementation for a database logger to build atop of. + * All that is needed for a concrete database logger is to extend this class + * and override the methods in the implementation file that are prefixed with "db_". +**/ + +@interface DDAbstractDatabaseLogger : DDAbstractLogger { +@protected + NSUInteger saveThreshold; + NSTimeInterval saveInterval; + NSTimeInterval maxAge; + NSTimeInterval deleteInterval; + BOOL deleteOnEverySave; + + BOOL saveTimerSuspended; + NSUInteger unsavedCount; + dispatch_time_t unsavedTime; + dispatch_source_t saveTimer; + dispatch_time_t lastDeleteTime; + dispatch_source_t deleteTimer; +} + +/** + * Specifies how often to save the data to disk. + * Since saving is an expensive operation (disk io) it is not done after every log statement. + * These properties allow you to configure how/when the logger saves to disk. + * + * A save is done when either (whichever happens first): + * + * - The number of unsaved log entries reaches saveThreshold + * - The amount of time since the oldest unsaved log entry was created reaches saveInterval + * + * You can optionally disable the saveThreshold by setting it to zero. + * If you disable the saveThreshold you are entirely dependent on the saveInterval. + * + * You can optionally disable the saveInterval by setting it to zero (or a negative value). + * If you disable the saveInterval you are entirely dependent on the saveThreshold. + * + * It's not wise to disable both saveThreshold and saveInterval. + * + * The default saveThreshold is 500. + * The default saveInterval is 60 seconds. +**/ +@property (assign, readwrite) NSUInteger saveThreshold; +@property (assign, readwrite) NSTimeInterval saveInterval; + +/** + * It is likely you don't want the log entries to persist forever. + * Doing so would allow the database to grow infinitely large over time. + * + * The maxAge property provides a way to specify how old a log statement can get + * before it should get deleted from the database. + * + * The deleteInterval specifies how often to sweep for old log entries. + * Since deleting is an expensive operation (disk io) is is done on a fixed interval. + * + * An alternative to the deleteInterval is the deleteOnEverySave option. + * This specifies that old log entries should be deleted during every save operation. + * + * You can optionally disable the maxAge by setting it to zero (or a negative value). + * If you disable the maxAge then old log statements are not deleted. + * + * You can optionally disable the deleteInterval by setting it to zero (or a negative value). + * + * If you disable both deleteInterval and deleteOnEverySave then old log statements are not deleted. + * + * It's not wise to enable both deleteInterval and deleteOnEverySave. + * + * The default maxAge is 7 days. + * The default deleteInterval is 5 minutes. + * The default deleteOnEverySave is NO. +**/ +@property (assign, readwrite) NSTimeInterval maxAge; +@property (assign, readwrite) NSTimeInterval deleteInterval; +@property (assign, readwrite) BOOL deleteOnEverySave; + +/** + * Forces a save of any pending log entries (flushes log entries to disk). +**/ +- (void)savePendingLogEntries; + +/** + * Removes any log entries that are older than maxAge. +**/ +- (void)deleteOldLogEntries; + +@end diff --git a/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m b/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m new file mode 100644 index 00000000..05fcbcb8 --- /dev/null +++ b/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m @@ -0,0 +1,727 @@ +#import "DDAbstractDatabaseLogger.h" +#import + +/** + * Welcome to Cocoa Lumberjack! + * + * The project page has a wealth of documentation if you have any questions. + * https://github.com/CocoaLumberjack/CocoaLumberjack + * + * If you're new to the project you may wish to read the "Getting Started" wiki. + * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted +**/ + +#if ! __has_feature(objc_arc) +#error This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC). +#endif + +@interface DDAbstractDatabaseLogger () +- (void)destroySaveTimer; +- (void)destroyDeleteTimer; +@end + +#pragma mark - + +@implementation DDAbstractDatabaseLogger + +- (id)init +{ + if ((self = [super init])) + { + saveThreshold = 500; + saveInterval = 60; // 60 seconds + maxAge = (60 * 60 * 24 * 7); // 7 days + deleteInterval = (60 * 5); // 5 minutes + } + return self; +} + +- (void)dealloc +{ + [self destroySaveTimer]; + [self destroyDeleteTimer]; + +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#pragma mark Override Me +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +- (BOOL)db_log:(DDLogMessage *)logMessage +{ + // Override me and add your implementation. + // + // Return YES if an item was added to the buffer. + // Return NO if the logMessage was ignored. + + return NO; +} + +- (void)db_save +{ + // Override me and add your implementation. +} + +- (void)db_delete +{ + // Override me and add your implementation. +} + +- (void)db_saveAndDelete +{ + // Override me and add your implementation. +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#pragma mark Private API +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +- (void)performSaveAndSuspendSaveTimer +{ + if (unsavedCount > 0) + { + if (deleteOnEverySave) + [self db_saveAndDelete]; + else + [self db_save]; + } + + unsavedCount = 0; + unsavedTime = 0; + + if (saveTimer && !saveTimerSuspended) + { + dispatch_suspend(saveTimer); + saveTimerSuspended = YES; + } +} + +- (void)performDelete +{ + if (maxAge > 0.0) + { + [self db_delete]; + + lastDeleteTime = dispatch_time(DISPATCH_TIME_NOW, 0); + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#pragma mark Timers +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +- (void)destroySaveTimer +{ + if (saveTimer) + { + dispatch_source_cancel(saveTimer); + if (saveTimerSuspended) + { + // Must resume a timer before releasing it (or it will crash) + dispatch_resume(saveTimer); + saveTimerSuspended = NO; + } + #if !OS_OBJECT_USE_OBJC + dispatch_release(saveTimer); + #endif + saveTimer = NULL; + } +} + +- (void)updateAndResumeSaveTimer +{ + if ((saveTimer != NULL) && (saveInterval > 0.0) && (unsavedTime > 0.0)) + { + uint64_t interval = (uint64_t)(saveInterval * NSEC_PER_SEC); + dispatch_time_t startTime = dispatch_time(unsavedTime, interval); + + dispatch_source_set_timer(saveTimer, startTime, interval, 1.0); + + if (saveTimerSuspended) + { + dispatch_resume(saveTimer); + saveTimerSuspended = NO; + } + } +} + +- (void)createSuspendedSaveTimer +{ + if ((saveTimer == NULL) && (saveInterval > 0.0)) + { + saveTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, loggerQueue); + + dispatch_source_set_event_handler(saveTimer, ^{ @autoreleasepool { + + [self performSaveAndSuspendSaveTimer]; + + }}); + + saveTimerSuspended = YES; + } +} + +- (void)destroyDeleteTimer +{ + if (deleteTimer) + { + dispatch_source_cancel(deleteTimer); + #if !OS_OBJECT_USE_OBJC + dispatch_release(deleteTimer); + #endif + deleteTimer = NULL; + } +} + +- (void)updateDeleteTimer +{ + if ((deleteTimer != NULL) && (deleteInterval > 0.0) && (maxAge > 0.0)) + { + uint64_t interval = (uint64_t)(deleteInterval * NSEC_PER_SEC); + dispatch_time_t startTime; + + if (lastDeleteTime > 0) + startTime = dispatch_time(lastDeleteTime, interval); + else + startTime = dispatch_time(DISPATCH_TIME_NOW, interval); + + dispatch_source_set_timer(deleteTimer, startTime, interval, 1.0); + } +} + +- (void)createAndStartDeleteTimer +{ + if ((deleteTimer == NULL) && (deleteInterval > 0.0) && (maxAge > 0.0)) + { + deleteTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, loggerQueue); + + if (deleteTimer != NULL) { + dispatch_source_set_event_handler(deleteTimer, ^{ @autoreleasepool { + + [self performDelete]; + + }}); + + [self updateDeleteTimer]; + + if (deleteTimer != NULL) dispatch_resume(deleteTimer); + } + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#pragma mark Configuration +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +- (NSUInteger)saveThreshold +{ + // The design of this method is taken from the DDAbstractLogger implementation. + // For extensive documentation please refer to the DDAbstractLogger implementation. + + // Note: The internal implementation MUST access the colorsEnabled variable directly, + // This method is designed explicitly for external access. + // + // Using "self." syntax to go through this method will cause immediate deadlock. + // This is the intended result. Fix it by accessing the ivar directly. + // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster. + + NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure"); + NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax."); + + dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue]; + + __block NSUInteger result; + + dispatch_sync(globalLoggingQueue, ^{ + dispatch_sync(loggerQueue, ^{ + result = saveThreshold; + }); + }); + + return result; +} + +- (void)setSaveThreshold:(NSUInteger)threshold +{ + dispatch_block_t block = ^{ @autoreleasepool { + + if (saveThreshold != threshold) + { + saveThreshold = threshold; + + // Since the saveThreshold has changed, + // we check to see if the current unsavedCount has surpassed the new threshold. + // + // If it has, we immediately save the log. + + if ((unsavedCount >= saveThreshold) && (saveThreshold > 0)) + { + [self performSaveAndSuspendSaveTimer]; + } + } + }}; + + // The design of the setter logic below is taken from the DDAbstractLogger implementation. + // For documentation please refer to the DDAbstractLogger implementation. + + if ([self isOnInternalLoggerQueue]) + { + block(); + } + else + { + dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue]; + NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure"); + + dispatch_async(globalLoggingQueue, ^{ + dispatch_async(loggerQueue, block); + }); + } +} + +- (NSTimeInterval)saveInterval +{ + // The design of this method is taken from the DDAbstractLogger implementation. + // For extensive documentation please refer to the DDAbstractLogger implementation. + + // Note: The internal implementation MUST access the colorsEnabled variable directly, + // This method is designed explicitly for external access. + // + // Using "self." syntax to go through this method will cause immediate deadlock. + // This is the intended result. Fix it by accessing the ivar directly. + // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster. + + NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure"); + NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax."); + + dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue]; + + __block NSTimeInterval result; + + dispatch_sync(globalLoggingQueue, ^{ + dispatch_sync(loggerQueue, ^{ + result = saveInterval; + }); + }); + + return result; +} + +- (void)setSaveInterval:(NSTimeInterval)interval +{ + dispatch_block_t block = ^{ @autoreleasepool { + + // C99 recommended floating point comparison macro + // Read: isLessThanOrGreaterThan(floatA, floatB) + + if (/* saveInterval != interval */ islessgreater(saveInterval, interval)) + { + saveInterval = interval; + + // There are several cases we need to handle here. + // + // 1. If the saveInterval was previously enabled and it just got disabled, + // then we need to stop the saveTimer. (And we might as well release it.) + // + // 2. If the saveInterval was previously disabled and it just got enabled, + // then we need to setup the saveTimer. (Plus we might need to do an immediate save.) + // + // 3. If the saveInterval increased, then we need to reset the timer so that it fires at the later date. + // + // 4. If the saveInterval decreased, then we need to reset the timer so that it fires at an earlier date. + // (Plus we might need to do an immediate save.) + + if (saveInterval > 0.0) + { + if (saveTimer == NULL) + { + // Handles #2 + // + // Since the saveTimer uses the unsavedTime to calculate it's first fireDate, + // if a save is needed the timer will fire immediately. + + [self createSuspendedSaveTimer]; + [self updateAndResumeSaveTimer]; + } + else + { + // Handles #3 + // Handles #4 + // + // Since the saveTimer uses the unsavedTime to calculate it's first fireDate, + // if a save is needed the timer will fire immediately. + + [self updateAndResumeSaveTimer]; + } + } + else if (saveTimer) + { + // Handles #1 + + [self destroySaveTimer]; + } + } + }}; + + // The design of the setter logic below is taken from the DDAbstractLogger implementation. + // For documentation please refer to the DDAbstractLogger implementation. + + if ([self isOnInternalLoggerQueue]) + { + block(); + } + else + { + dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue]; + NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure"); + + dispatch_async(globalLoggingQueue, ^{ + dispatch_async(loggerQueue, block); + }); + } +} + +- (NSTimeInterval)maxAge +{ + // The design of this method is taken from the DDAbstractLogger implementation. + // For extensive documentation please refer to the DDAbstractLogger implementation. + + // Note: The internal implementation MUST access the colorsEnabled variable directly, + // This method is designed explicitly for external access. + // + // Using "self." syntax to go through this method will cause immediate deadlock. + // This is the intended result. Fix it by accessing the ivar directly. + // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster. + + NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure"); + NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax."); + + dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue]; + + __block NSTimeInterval result; + + dispatch_sync(globalLoggingQueue, ^{ + dispatch_sync(loggerQueue, ^{ + result = maxAge; + }); + }); + + return result; +} + +- (void)setMaxAge:(NSTimeInterval)interval +{ + dispatch_block_t block = ^{ @autoreleasepool { + + // C99 recommended floating point comparison macro + // Read: isLessThanOrGreaterThan(floatA, floatB) + + if (/* maxAge != interval */ islessgreater(maxAge, interval)) + { + NSTimeInterval oldMaxAge = maxAge; + NSTimeInterval newMaxAge = interval; + + maxAge = interval; + + // There are several cases we need to handle here. + // + // 1. If the maxAge was previously enabled and it just got disabled, + // then we need to stop the deleteTimer. (And we might as well release it.) + // + // 2. If the maxAge was previously disabled and it just got enabled, + // then we need to setup the deleteTimer. (Plus we might need to do an immediate delete.) + // + // 3. If the maxAge was increased, + // then we don't need to do anything. + // + // 4. If the maxAge was decreased, + // then we should do an immediate delete. + + BOOL shouldDeleteNow = NO; + + if (oldMaxAge > 0.0) + { + if (newMaxAge <= 0.0) + { + // Handles #1 + + [self destroyDeleteTimer]; + } + else if (oldMaxAge > newMaxAge) + { + // Handles #4 + shouldDeleteNow = YES; + } + } + else if (newMaxAge > 0.0) + { + // Handles #2 + shouldDeleteNow = YES; + } + + if (shouldDeleteNow) + { + [self performDelete]; + + if (deleteTimer) + [self updateDeleteTimer]; + else + [self createAndStartDeleteTimer]; + } + } + }}; + + // The design of the setter logic below is taken from the DDAbstractLogger implementation. + // For documentation please refer to the DDAbstractLogger implementation. + + if ([self isOnInternalLoggerQueue]) + { + block(); + } + else + { + dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue]; + NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure"); + + dispatch_async(globalLoggingQueue, ^{ + dispatch_async(loggerQueue, block); + }); + } +} + +- (NSTimeInterval)deleteInterval +{ + // The design of this method is taken from the DDAbstractLogger implementation. + // For extensive documentation please refer to the DDAbstractLogger implementation. + + // Note: The internal implementation MUST access the colorsEnabled variable directly, + // This method is designed explicitly for external access. + // + // Using "self." syntax to go through this method will cause immediate deadlock. + // This is the intended result. Fix it by accessing the ivar directly. + // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster. + + NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure"); + NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax."); + + dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue]; + + __block NSTimeInterval result; + + dispatch_sync(globalLoggingQueue, ^{ + dispatch_sync(loggerQueue, ^{ + result = deleteInterval; + }); + }); + + return result; +} + +- (void)setDeleteInterval:(NSTimeInterval)interval +{ + dispatch_block_t block = ^{ @autoreleasepool { + + // C99 recommended floating point comparison macro + // Read: isLessThanOrGreaterThan(floatA, floatB) + + if (/* deleteInterval != interval */ islessgreater(deleteInterval, interval)) + { + deleteInterval = interval; + + // There are several cases we need to handle here. + // + // 1. If the deleteInterval was previously enabled and it just got disabled, + // then we need to stop the deleteTimer. (And we might as well release it.) + // + // 2. If the deleteInterval was previously disabled and it just got enabled, + // then we need to setup the deleteTimer. (Plus we might need to do an immediate delete.) + // + // 3. If the deleteInterval increased, then we need to reset the timer so that it fires at the later date. + // + // 4. If the deleteInterval decreased, then we need to reset the timer so that it fires at an earlier date. + // (Plus we might need to do an immediate delete.) + + if (deleteInterval > 0.0) + { + if (deleteTimer == NULL) + { + // Handles #2 + // + // Since the deleteTimer uses the lastDeleteTime to calculate it's first fireDate, + // if a delete is needed the timer will fire immediately. + + [self createAndStartDeleteTimer]; + } + else + { + // Handles #3 + // Handles #4 + // + // Since the deleteTimer uses the lastDeleteTime to calculate it's first fireDate, + // if a save is needed the timer will fire immediately. + + [self updateDeleteTimer]; + } + } + else if (deleteTimer) + { + // Handles #1 + + [self destroyDeleteTimer]; + } + } + }}; + + // The design of the setter logic below is taken from the DDAbstractLogger implementation. + // For documentation please refer to the DDAbstractLogger implementation. + + if ([self isOnInternalLoggerQueue]) + { + block(); + } + else + { + dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue]; + NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure"); + + dispatch_async(globalLoggingQueue, ^{ + dispatch_async(loggerQueue, block); + }); + } +} + +- (BOOL)deleteOnEverySave +{ + // The design of this method is taken from the DDAbstractLogger implementation. + // For extensive documentation please refer to the DDAbstractLogger implementation. + + // Note: The internal implementation MUST access the colorsEnabled variable directly, + // This method is designed explicitly for external access. + // + // Using "self." syntax to go through this method will cause immediate deadlock. + // This is the intended result. Fix it by accessing the ivar directly. + // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster. + + NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure"); + NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax."); + + dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue]; + + __block BOOL result; + + dispatch_sync(globalLoggingQueue, ^{ + dispatch_sync(loggerQueue, ^{ + result = deleteOnEverySave; + }); + }); + + return result; +} + +- (void)setDeleteOnEverySave:(BOOL)flag +{ + dispatch_block_t block = ^{ + + deleteOnEverySave = flag; + }; + + // The design of the setter logic below is taken from the DDAbstractLogger implementation. + // For documentation please refer to the DDAbstractLogger implementation. + + if ([self isOnInternalLoggerQueue]) + { + block(); + } + else + { + dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue]; + NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure"); + + dispatch_async(globalLoggingQueue, ^{ + dispatch_async(loggerQueue, block); + }); + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#pragma mark Public API +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +- (void)savePendingLogEntries +{ + dispatch_block_t block = ^{ @autoreleasepool { + + [self performSaveAndSuspendSaveTimer]; + }}; + + if ([self isOnInternalLoggerQueue]) + block(); + else + dispatch_async(loggerQueue, block); +} + +- (void)deleteOldLogEntries +{ + dispatch_block_t block = ^{ @autoreleasepool { + + [self performDelete]; + }}; + + if ([self isOnInternalLoggerQueue]) + block(); + else + dispatch_async(loggerQueue, block); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#pragma mark DDLogger +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +- (void)didAddLogger +{ + // If you override me be sure to invoke [super didAddLogger]; + + [self createSuspendedSaveTimer]; + + [self createAndStartDeleteTimer]; +} + +- (void)willRemoveLogger +{ + // If you override me be sure to invoke [super willRemoveLogger]; + + [self performSaveAndSuspendSaveTimer]; + + [self destroySaveTimer]; + [self destroyDeleteTimer]; +} + +- (void)logMessage:(DDLogMessage *)logMessage +{ + if ([self db_log:logMessage]) + { + BOOL firstUnsavedEntry = (++unsavedCount == 1); + + if ((unsavedCount >= saveThreshold) && (saveThreshold > 0)) + { + [self performSaveAndSuspendSaveTimer]; + } + else if (firstUnsavedEntry) + { + unsavedTime = dispatch_time(DISPATCH_TIME_NOW, 0); + [self updateAndResumeSaveTimer]; + } + } +} + +- (void)flush +{ + // This method is invoked by DDLog's flushLog method. + // + // It is called automatically when the application quits, + // or if the developer invokes DDLog's flushLog method prior to crashing or something. + + [self performSaveAndSuspendSaveTimer]; +} + +@end diff --git a/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h b/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h new file mode 100644 index 00000000..a244ff63 --- /dev/null +++ b/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h @@ -0,0 +1,387 @@ +#import +#import "DDLog.h" + +@class DDLogFileInfo; + +/** + * Welcome to Cocoa Lumberjack! + * + * The project page has a wealth of documentation if you have any questions. + * https://github.com/CocoaLumberjack/CocoaLumberjack + * + * If you're new to the project you may wish to read the "Getting Started" wiki. + * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted + * + * + * This class provides a logger to write log statements to a file. +**/ + + +// Default configuration and safety/sanity values. +// +// maximumFileSize -> DEFAULT_LOG_MAX_FILE_SIZE +// rollingFrequency -> DEFAULT_LOG_ROLLING_FREQUENCY +// maximumNumberOfLogFiles -> DEFAULT_LOG_MAX_NUM_LOG_FILES +// +// You should carefully consider the proper configuration values for your application. + +#define DEFAULT_LOG_MAX_FILE_SIZE (1024 * 1024) // 1 MB +#define DEFAULT_LOG_ROLLING_FREQUENCY (60 * 60 * 24) // 24 Hours +#define DEFAULT_LOG_MAX_NUM_LOG_FILES (5) // 5 Files + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#pragma mark - +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +// The LogFileManager protocol is designed to allow you to control all aspects of your log files. +// +// The primary purpose of this is to allow you to do something with the log files after they have been rolled. +// Perhaps you want to compress them to save disk space. +// Perhaps you want to upload them to an FTP server. +// Perhaps you want to run some analytics on the file. +// +// A default LogFileManager is, of course, provided. +// The default LogFileManager simply deletes old log files according to the maximumNumberOfLogFiles property. +// +// This protocol provides various methods to fetch the list of log files. +// +// There are two variants: sorted and unsorted. +// If sorting is not necessary, the unsorted variant is obviously faster. +// The sorted variant will return an array sorted by when the log files were created, +// with the most recently created log file at index 0, and the oldest log file at the end of the array. +// +// You can fetch only the log file paths (full path including name), log file names (name only), +// or an array of DDLogFileInfo objects. +// The DDLogFileInfo class is documented below, and provides a handy wrapper that +// gives you easy access to various file attributes such as the creation date or the file size. + +@protocol DDLogFileManager +@required + +// Public properties + +/** + * The maximum number of archived log files to keep on disk. + * For example, if this property is set to 3, + * then the LogFileManager will only keep 3 archived log files (plus the current active log file) on disk. + * Once the active log file is rolled/archived, then the oldest of the existing 3 rolled/archived log files is deleted. + * + * You may optionally disable deleting old/rolled/archived log files by setting this property to zero. +**/ +@property (readwrite, assign, atomic) NSUInteger maximumNumberOfLogFiles; + +// Public methods + +- (NSString *)logsDirectory; + +- (NSArray *)unsortedLogFilePaths; +- (NSArray *)unsortedLogFileNames; +- (NSArray *)unsortedLogFileInfos; + +- (NSArray *)sortedLogFilePaths; +- (NSArray *)sortedLogFileNames; +- (NSArray *)sortedLogFileInfos; + +// Private methods (only to be used by DDFileLogger) + +- (NSString *)createNewLogFile; + +@optional + +// Notifications from DDFileLogger + +- (void)didArchiveLogFile:(NSString *)logFilePath; +- (void)didRollAndArchiveLogFile:(NSString *)logFilePath; + +@end + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#pragma mark - +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * Default log file manager. + * + * All log files are placed inside the logsDirectory. + * If a specific logsDirectory isn't specified, the default directory is used. + * On Mac, this is in ~/Library/Logs/. + * On iPhone, this is in ~/Library/Caches/Logs. + * + * Log files are named "