├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── ScreenShot ├── ScreenShot1.PNG ├── ScreenShot2.PNG └── ScreenShot3.PNG ├── SuperLogger.podspec ├── SuperLogger.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── SuperLogger.xcscheme ├── SuperLogger.xcworkspace └── contents.xcworkspacedata ├── SuperLogger ├── Info.plist ├── Resources │ └── SuperLogger.bundle │ │ ├── Base.lproj │ │ └── SLLocalizable.strings │ │ ├── Info.plist │ │ ├── de.lproj │ │ └── SLLocalizable.strings │ │ ├── en.lproj │ │ └── SLLocalizable.strings │ │ ├── pl-PL.lproj │ │ └── SLLocalizable.strings │ │ └── zh_CN.lproj │ │ └── SLLocalizable.strings ├── SuperLogerListView.h ├── SuperLogerListView.m ├── SuperLogger.h ├── SuperLogger.m ├── SuperLoggerFunctions.h ├── SuperLoggerFunctions.m ├── SuperLoggerPreviewView.h └── SuperLoggerPreviewView.m ├── SuperLoggerDemo ├── SuperLoggerDemo.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── SuperLoggerDemo │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard │ ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m └── SuperLoggerTests ├── Info.plist ├── SuperLoggerFunctionsTest.m └── SuperLoggerTests.m /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | 3 | before_install: 4 | - brew update 5 | - brew outdated xctool || brew upgrade xctool 6 | script: xctool -project SuperLogger.xcodeproj -scheme SuperLogger -sdk iphonesimulator test 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 郭宇翔 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SuperLogger 2 | =========== 3 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 4 | [![Version](https://img.shields.io/cocoapods/v/SuperLogger.svg?style=flat)](http://cocoapods.org/pods/SuperLogger) 5 | [![License](https://img.shields.io/cocoapods/l/SuperLogger.svg?style=flat)](http://cocoapods.org/pods/SuperLogger) 6 | [![Platform](https://img.shields.io/cocoapods/p/SuperLogger.svg?style=flat)](http://cocoapods.org/pods/SuperLogger) 7 | [![Build Status](https://travis-ci.org/yourtion/SuperLogger.svg?branch=master)](https://travis-ci.org/yourtion/SuperLogger) 8 | 9 | Save NSLog() to file and send email to developer 10 | 11 | ## Installation 12 | 13 | The preferred way of installation is via CocoaPods. Just add 14 | 15 | ```ruby 16 | pod 'SuperLogger' 17 | ``` 18 | 19 | and run pod install. It will install the most recent version of SuperLogger. 20 | 21 | ## How to use 22 | 23 | Import the framework header on AppDelegate.m: 24 | 25 | ```objective-c 26 | #import "SuperLogger.h" 27 | ``` 28 | 29 | Init and set email info: 30 | 31 | ```objective-c 32 | SuperLogger *logger = [SuperLogger sharedInstance]; 33 | // Start NSLogToDocument 34 | [logger redirectNSLogToDocumentFolder]; 35 | // Set Email info 36 | logger.mailTitle = @"SuperLoggerDemo Logfile"; 37 | logger.mailContect = @"This is the SuperLoggerDemo Logfile"; 38 | logger.mailRecipients = @[@"yourtion@gmail.com"]; 39 | ``` 40 | 41 | That's it! Have fun with SuperLogger! 42 | 43 | Show the Loglist by presentViewController "[[SuperLogger sharedInstance] getListView]" 44 | 45 | ```objective-c 46 | [self presentViewController:[[SuperLogger sharedInstance] getListView] animated:YES completion:nil]; 47 | ``` 48 | 49 | ## ScreenShot 50 | 51 | ![ScreenShot1](ScreenShot/ScreenShot1.PNG) 52 | 53 | ![ScreenShot1](ScreenShot/ScreenShot2.PNG) 54 | 55 | ![ScreenShot1](ScreenShot/ScreenShot3.PNG) 56 | -------------------------------------------------------------------------------- /ScreenShot/ScreenShot1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/SuperLogger/10d37b4aa9b321532418e4fd93e5b7b99284d1e8/ScreenShot/ScreenShot1.PNG -------------------------------------------------------------------------------- /ScreenShot/ScreenShot2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/SuperLogger/10d37b4aa9b321532418e4fd93e5b7b99284d1e8/ScreenShot/ScreenShot2.PNG -------------------------------------------------------------------------------- /ScreenShot/ScreenShot3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/SuperLogger/10d37b4aa9b321532418e4fd93e5b7b99284d1e8/ScreenShot/ScreenShot3.PNG -------------------------------------------------------------------------------- /SuperLogger.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "SuperLogger" 4 | s.version = "0.9.3" 5 | s.summary = "Save NSLog() to file and send email to developer." 6 | 7 | s.description = <<-DESC 8 | Save NSLog() to file and send email to developer. 9 | 10 | * Think: Why did you write this? What is the focus? What does it do? 11 | * CocoaPods will be using this to generate tags, and improve search results. 12 | * Try to keep it short, snappy and to the point. 13 | * Finally, don't worry about the indent, CocoaPods strips it! 14 | DESC 15 | 16 | s.homepage = "https://github.com/yourtion/SuperLogger" 17 | s.screenshots = "https://raw.githubusercontent.com/yourtion/SuperLogger/master/ScreenShot/ScreenShot1.PNG", "https://raw.githubusercontent.com/yourtion/SuperLogger/master/ScreenShot/ScreenShot2.PNG", "https://raw.githubusercontent.com/yourtion/SuperLogger/master/ScreenShot/ScreenShot3.PNG" 18 | 19 | s.license = "MIT" 20 | s.author = { "Yourtion" => "yourtion@gmail.com" } 21 | s.platform = :ios 22 | s.source = { :git => "https://github.com/yourtion/SuperLogger.git", :tag => s.version } 23 | s.source_files = "SuperLogger" 24 | s.resources = ["SuperLogger/Resources/**/*.bundle"] 25 | s.frameworks = "Foundation", "UIKit", "MessageUI" 26 | s.requires_arc = true 27 | 28 | end 29 | -------------------------------------------------------------------------------- /SuperLogger.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | CB0005491C76D26000FC3E1A /* SuperLogger.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CB00053E1C76D26000FC3E1A /* SuperLogger.framework */; }; 11 | CB00054E1C76D26000FC3E1A /* SuperLoggerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CB00054D1C76D26000FC3E1A /* SuperLoggerTests.m */; }; 12 | CB0005621C76D29700FC3E1A /* SuperLogger.bundle in Resources */ = {isa = PBXBuildFile; fileRef = CB0005591C76D29700FC3E1A /* SuperLogger.bundle */; }; 13 | CB0005631C76D29700FC3E1A /* SuperLogerListView.h in Headers */ = {isa = PBXBuildFile; fileRef = CB00055A1C76D29700FC3E1A /* SuperLogerListView.h */; }; 14 | CB0005641C76D29700FC3E1A /* SuperLogerListView.m in Sources */ = {isa = PBXBuildFile; fileRef = CB00055B1C76D29700FC3E1A /* SuperLogerListView.m */; }; 15 | CB0005651C76D29700FC3E1A /* SuperLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = CB00055C1C76D29700FC3E1A /* SuperLogger.h */; settings = {ATTRIBUTES = (Public, ); }; }; 16 | CB0005661C76D29700FC3E1A /* SuperLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = CB00055D1C76D29700FC3E1A /* SuperLogger.m */; }; 17 | CB0005671C76D29700FC3E1A /* SuperLoggerFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = CB00055E1C76D29700FC3E1A /* SuperLoggerFunctions.h */; }; 18 | CB0005681C76D29700FC3E1A /* SuperLoggerFunctions.m in Sources */ = {isa = PBXBuildFile; fileRef = CB00055F1C76D29700FC3E1A /* SuperLoggerFunctions.m */; }; 19 | CB0005691C76D29700FC3E1A /* SuperLoggerPreviewView.h in Headers */ = {isa = PBXBuildFile; fileRef = CB0005601C76D29700FC3E1A /* SuperLoggerPreviewView.h */; }; 20 | CB00056A1C76D29700FC3E1A /* SuperLoggerPreviewView.m in Sources */ = {isa = PBXBuildFile; fileRef = CB0005611C76D29700FC3E1A /* SuperLoggerPreviewView.m */; }; 21 | CB00056C1C76E51F00FC3E1A /* SuperLoggerFunctionsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CB00056B1C76E51F00FC3E1A /* SuperLoggerFunctionsTest.m */; }; 22 | CBACBE8B1D44B0640096C5F8 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CBACBE8A1D44B0640096C5F8 /* UIKit.framework */; }; 23 | CBACBE8D1D44B0BD0096C5F8 /* MessageUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CBACBE8C1D44B0BD0096C5F8 /* MessageUI.framework */; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXContainerItemProxy section */ 27 | CB00054A1C76D26000FC3E1A /* PBXContainerItemProxy */ = { 28 | isa = PBXContainerItemProxy; 29 | containerPortal = CB0005351C76D26000FC3E1A /* Project object */; 30 | proxyType = 1; 31 | remoteGlobalIDString = CB00053D1C76D26000FC3E1A; 32 | remoteInfo = SuperLogger; 33 | }; 34 | /* End PBXContainerItemProxy section */ 35 | 36 | /* Begin PBXFileReference section */ 37 | CB00053E1C76D26000FC3E1A /* SuperLogger.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SuperLogger.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | CB0005431C76D26000FC3E1A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 39 | CB0005481C76D26000FC3E1A /* SuperLoggerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SuperLoggerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | CB00054D1C76D26000FC3E1A /* SuperLoggerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SuperLoggerTests.m; sourceTree = ""; }; 41 | CB00054F1C76D26000FC3E1A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 42 | CB0005591C76D29700FC3E1A /* SuperLogger.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = SuperLogger.bundle; sourceTree = ""; }; 43 | CB00055A1C76D29700FC3E1A /* SuperLogerListView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SuperLogerListView.h; sourceTree = ""; }; 44 | CB00055B1C76D29700FC3E1A /* SuperLogerListView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SuperLogerListView.m; sourceTree = ""; }; 45 | CB00055C1C76D29700FC3E1A /* SuperLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SuperLogger.h; sourceTree = ""; }; 46 | CB00055D1C76D29700FC3E1A /* SuperLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SuperLogger.m; sourceTree = ""; }; 47 | CB00055E1C76D29700FC3E1A /* SuperLoggerFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SuperLoggerFunctions.h; sourceTree = ""; }; 48 | CB00055F1C76D29700FC3E1A /* SuperLoggerFunctions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SuperLoggerFunctions.m; sourceTree = ""; }; 49 | CB0005601C76D29700FC3E1A /* SuperLoggerPreviewView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SuperLoggerPreviewView.h; sourceTree = ""; }; 50 | CB0005611C76D29700FC3E1A /* SuperLoggerPreviewView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SuperLoggerPreviewView.m; sourceTree = ""; }; 51 | CB00056B1C76E51F00FC3E1A /* SuperLoggerFunctionsTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SuperLoggerFunctionsTest.m; sourceTree = ""; }; 52 | CBACBE8A1D44B0640096C5F8 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 53 | CBACBE8C1D44B0BD0096C5F8 /* MessageUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MessageUI.framework; path = System/Library/Frameworks/MessageUI.framework; sourceTree = SDKROOT; }; 54 | /* End PBXFileReference section */ 55 | 56 | /* Begin PBXFrameworksBuildPhase section */ 57 | CB00053A1C76D26000FC3E1A /* Frameworks */ = { 58 | isa = PBXFrameworksBuildPhase; 59 | buildActionMask = 2147483647; 60 | files = ( 61 | CBACBE8D1D44B0BD0096C5F8 /* MessageUI.framework in Frameworks */, 62 | CBACBE8B1D44B0640096C5F8 /* UIKit.framework in Frameworks */, 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | CB0005451C76D26000FC3E1A /* Frameworks */ = { 67 | isa = PBXFrameworksBuildPhase; 68 | buildActionMask = 2147483647; 69 | files = ( 70 | CB0005491C76D26000FC3E1A /* SuperLogger.framework in Frameworks */, 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | /* End PBXFrameworksBuildPhase section */ 75 | 76 | /* Begin PBXGroup section */ 77 | CB0005341C76D26000FC3E1A = { 78 | isa = PBXGroup; 79 | children = ( 80 | CBACBE8C1D44B0BD0096C5F8 /* MessageUI.framework */, 81 | CBACBE8A1D44B0640096C5F8 /* UIKit.framework */, 82 | CB0005401C76D26000FC3E1A /* SuperLogger */, 83 | CB00054C1C76D26000FC3E1A /* SuperLoggerTests */, 84 | CB00053F1C76D26000FC3E1A /* Products */, 85 | ); 86 | sourceTree = ""; 87 | }; 88 | CB00053F1C76D26000FC3E1A /* Products */ = { 89 | isa = PBXGroup; 90 | children = ( 91 | CB00053E1C76D26000FC3E1A /* SuperLogger.framework */, 92 | CB0005481C76D26000FC3E1A /* SuperLoggerTests.xctest */, 93 | ); 94 | name = Products; 95 | sourceTree = ""; 96 | }; 97 | CB0005401C76D26000FC3E1A /* SuperLogger */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | CB0005581C76D29700FC3E1A /* Resources */, 101 | CB00055A1C76D29700FC3E1A /* SuperLogerListView.h */, 102 | CB00055B1C76D29700FC3E1A /* SuperLogerListView.m */, 103 | CB00055C1C76D29700FC3E1A /* SuperLogger.h */, 104 | CB00055D1C76D29700FC3E1A /* SuperLogger.m */, 105 | CB00055E1C76D29700FC3E1A /* SuperLoggerFunctions.h */, 106 | CB00055F1C76D29700FC3E1A /* SuperLoggerFunctions.m */, 107 | CB0005601C76D29700FC3E1A /* SuperLoggerPreviewView.h */, 108 | CB0005611C76D29700FC3E1A /* SuperLoggerPreviewView.m */, 109 | CB0005431C76D26000FC3E1A /* Info.plist */, 110 | ); 111 | path = SuperLogger; 112 | sourceTree = ""; 113 | }; 114 | CB00054C1C76D26000FC3E1A /* SuperLoggerTests */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | CB00054D1C76D26000FC3E1A /* SuperLoggerTests.m */, 118 | CB00056B1C76E51F00FC3E1A /* SuperLoggerFunctionsTest.m */, 119 | CB00054F1C76D26000FC3E1A /* Info.plist */, 120 | ); 121 | path = SuperLoggerTests; 122 | sourceTree = ""; 123 | }; 124 | CB0005581C76D29700FC3E1A /* Resources */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | CB0005591C76D29700FC3E1A /* SuperLogger.bundle */, 128 | ); 129 | path = Resources; 130 | sourceTree = ""; 131 | }; 132 | /* End PBXGroup section */ 133 | 134 | /* Begin PBXHeadersBuildPhase section */ 135 | CB00053B1C76D26000FC3E1A /* Headers */ = { 136 | isa = PBXHeadersBuildPhase; 137 | buildActionMask = 2147483647; 138 | files = ( 139 | CB0005651C76D29700FC3E1A /* SuperLogger.h in Headers */, 140 | CB0005671C76D29700FC3E1A /* SuperLoggerFunctions.h in Headers */, 141 | CB0005691C76D29700FC3E1A /* SuperLoggerPreviewView.h in Headers */, 142 | CB0005631C76D29700FC3E1A /* SuperLogerListView.h in Headers */, 143 | ); 144 | runOnlyForDeploymentPostprocessing = 0; 145 | }; 146 | /* End PBXHeadersBuildPhase section */ 147 | 148 | /* Begin PBXNativeTarget section */ 149 | CB00053D1C76D26000FC3E1A /* SuperLogger */ = { 150 | isa = PBXNativeTarget; 151 | buildConfigurationList = CB0005521C76D26000FC3E1A /* Build configuration list for PBXNativeTarget "SuperLogger" */; 152 | buildPhases = ( 153 | CB0005391C76D26000FC3E1A /* Sources */, 154 | CB00053A1C76D26000FC3E1A /* Frameworks */, 155 | CB00053B1C76D26000FC3E1A /* Headers */, 156 | CB00053C1C76D26000FC3E1A /* Resources */, 157 | ); 158 | buildRules = ( 159 | ); 160 | dependencies = ( 161 | ); 162 | name = SuperLogger; 163 | productName = SuperLogger; 164 | productReference = CB00053E1C76D26000FC3E1A /* SuperLogger.framework */; 165 | productType = "com.apple.product-type.framework"; 166 | }; 167 | CB0005471C76D26000FC3E1A /* SuperLoggerTests */ = { 168 | isa = PBXNativeTarget; 169 | buildConfigurationList = CB0005551C76D26000FC3E1A /* Build configuration list for PBXNativeTarget "SuperLoggerTests" */; 170 | buildPhases = ( 171 | CB0005441C76D26000FC3E1A /* Sources */, 172 | CB0005451C76D26000FC3E1A /* Frameworks */, 173 | CB0005461C76D26000FC3E1A /* Resources */, 174 | ); 175 | buildRules = ( 176 | ); 177 | dependencies = ( 178 | CB00054B1C76D26000FC3E1A /* PBXTargetDependency */, 179 | ); 180 | name = SuperLoggerTests; 181 | productName = SuperLoggerTests; 182 | productReference = CB0005481C76D26000FC3E1A /* SuperLoggerTests.xctest */; 183 | productType = "com.apple.product-type.bundle.unit-test"; 184 | }; 185 | /* End PBXNativeTarget section */ 186 | 187 | /* Begin PBXProject section */ 188 | CB0005351C76D26000FC3E1A /* Project object */ = { 189 | isa = PBXProject; 190 | attributes = { 191 | LastUpgradeCheck = 0810; 192 | ORGANIZATIONNAME = Yourtion; 193 | TargetAttributes = { 194 | CB00053D1C76D26000FC3E1A = { 195 | CreatedOnToolsVersion = 7.2.1; 196 | }; 197 | CB0005471C76D26000FC3E1A = { 198 | CreatedOnToolsVersion = 7.2.1; 199 | }; 200 | }; 201 | }; 202 | buildConfigurationList = CB0005381C76D26000FC3E1A /* Build configuration list for PBXProject "SuperLogger" */; 203 | compatibilityVersion = "Xcode 3.2"; 204 | developmentRegion = English; 205 | hasScannedForEncodings = 0; 206 | knownRegions = ( 207 | en, 208 | ); 209 | mainGroup = CB0005341C76D26000FC3E1A; 210 | productRefGroup = CB00053F1C76D26000FC3E1A /* Products */; 211 | projectDirPath = ""; 212 | projectRoot = ""; 213 | targets = ( 214 | CB00053D1C76D26000FC3E1A /* SuperLogger */, 215 | CB0005471C76D26000FC3E1A /* SuperLoggerTests */, 216 | ); 217 | }; 218 | /* End PBXProject section */ 219 | 220 | /* Begin PBXResourcesBuildPhase section */ 221 | CB00053C1C76D26000FC3E1A /* Resources */ = { 222 | isa = PBXResourcesBuildPhase; 223 | buildActionMask = 2147483647; 224 | files = ( 225 | CB0005621C76D29700FC3E1A /* SuperLogger.bundle in Resources */, 226 | ); 227 | runOnlyForDeploymentPostprocessing = 0; 228 | }; 229 | CB0005461C76D26000FC3E1A /* Resources */ = { 230 | isa = PBXResourcesBuildPhase; 231 | buildActionMask = 2147483647; 232 | files = ( 233 | ); 234 | runOnlyForDeploymentPostprocessing = 0; 235 | }; 236 | /* End PBXResourcesBuildPhase section */ 237 | 238 | /* Begin PBXSourcesBuildPhase section */ 239 | CB0005391C76D26000FC3E1A /* Sources */ = { 240 | isa = PBXSourcesBuildPhase; 241 | buildActionMask = 2147483647; 242 | files = ( 243 | CB0005641C76D29700FC3E1A /* SuperLogerListView.m in Sources */, 244 | CB0005681C76D29700FC3E1A /* SuperLoggerFunctions.m in Sources */, 245 | CB0005661C76D29700FC3E1A /* SuperLogger.m in Sources */, 246 | CB00056A1C76D29700FC3E1A /* SuperLoggerPreviewView.m in Sources */, 247 | ); 248 | runOnlyForDeploymentPostprocessing = 0; 249 | }; 250 | CB0005441C76D26000FC3E1A /* Sources */ = { 251 | isa = PBXSourcesBuildPhase; 252 | buildActionMask = 2147483647; 253 | files = ( 254 | CB00054E1C76D26000FC3E1A /* SuperLoggerTests.m in Sources */, 255 | CB00056C1C76E51F00FC3E1A /* SuperLoggerFunctionsTest.m in Sources */, 256 | ); 257 | runOnlyForDeploymentPostprocessing = 0; 258 | }; 259 | /* End PBXSourcesBuildPhase section */ 260 | 261 | /* Begin PBXTargetDependency section */ 262 | CB00054B1C76D26000FC3E1A /* PBXTargetDependency */ = { 263 | isa = PBXTargetDependency; 264 | target = CB00053D1C76D26000FC3E1A /* SuperLogger */; 265 | targetProxy = CB00054A1C76D26000FC3E1A /* PBXContainerItemProxy */; 266 | }; 267 | /* End PBXTargetDependency section */ 268 | 269 | /* Begin XCBuildConfiguration section */ 270 | CB0005501C76D26000FC3E1A /* Debug */ = { 271 | isa = XCBuildConfiguration; 272 | buildSettings = { 273 | ALWAYS_SEARCH_USER_PATHS = NO; 274 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 275 | CLANG_CXX_LIBRARY = "libc++"; 276 | CLANG_ENABLE_MODULES = YES; 277 | CLANG_ENABLE_OBJC_ARC = YES; 278 | CLANG_WARN_BOOL_CONVERSION = YES; 279 | CLANG_WARN_CONSTANT_CONVERSION = YES; 280 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 281 | CLANG_WARN_EMPTY_BODY = YES; 282 | CLANG_WARN_ENUM_CONVERSION = YES; 283 | CLANG_WARN_INFINITE_RECURSION = YES; 284 | CLANG_WARN_INT_CONVERSION = YES; 285 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 286 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 287 | CLANG_WARN_UNREACHABLE_CODE = YES; 288 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 289 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 290 | COPY_PHASE_STRIP = NO; 291 | CURRENT_PROJECT_VERSION = 1; 292 | DEBUG_INFORMATION_FORMAT = dwarf; 293 | ENABLE_STRICT_OBJC_MSGSEND = YES; 294 | ENABLE_TESTABILITY = YES; 295 | GCC_C_LANGUAGE_STANDARD = gnu99; 296 | GCC_DYNAMIC_NO_PIC = NO; 297 | GCC_NO_COMMON_BLOCKS = YES; 298 | GCC_OPTIMIZATION_LEVEL = 0; 299 | GCC_PREPROCESSOR_DEFINITIONS = ( 300 | "DEBUG=1", 301 | "$(inherited)", 302 | ); 303 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 304 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 305 | GCC_WARN_UNDECLARED_SELECTOR = YES; 306 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 307 | GCC_WARN_UNUSED_FUNCTION = YES; 308 | GCC_WARN_UNUSED_VARIABLE = YES; 309 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 310 | MTL_ENABLE_DEBUG_INFO = YES; 311 | ONLY_ACTIVE_ARCH = YES; 312 | SDKROOT = iphoneos; 313 | TARGETED_DEVICE_FAMILY = "1,2"; 314 | VERSIONING_SYSTEM = "apple-generic"; 315 | VERSION_INFO_PREFIX = ""; 316 | }; 317 | name = Debug; 318 | }; 319 | CB0005511C76D26000FC3E1A /* Release */ = { 320 | isa = XCBuildConfiguration; 321 | buildSettings = { 322 | ALWAYS_SEARCH_USER_PATHS = NO; 323 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 324 | CLANG_CXX_LIBRARY = "libc++"; 325 | CLANG_ENABLE_MODULES = YES; 326 | CLANG_ENABLE_OBJC_ARC = YES; 327 | CLANG_WARN_BOOL_CONVERSION = YES; 328 | CLANG_WARN_CONSTANT_CONVERSION = YES; 329 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 330 | CLANG_WARN_EMPTY_BODY = YES; 331 | CLANG_WARN_ENUM_CONVERSION = YES; 332 | CLANG_WARN_INFINITE_RECURSION = YES; 333 | CLANG_WARN_INT_CONVERSION = YES; 334 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 335 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 336 | CLANG_WARN_UNREACHABLE_CODE = YES; 337 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 338 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 339 | COPY_PHASE_STRIP = NO; 340 | CURRENT_PROJECT_VERSION = 1; 341 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 342 | ENABLE_NS_ASSERTIONS = NO; 343 | ENABLE_STRICT_OBJC_MSGSEND = YES; 344 | GCC_C_LANGUAGE_STANDARD = gnu99; 345 | GCC_NO_COMMON_BLOCKS = YES; 346 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 347 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 348 | GCC_WARN_UNDECLARED_SELECTOR = YES; 349 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 350 | GCC_WARN_UNUSED_FUNCTION = YES; 351 | GCC_WARN_UNUSED_VARIABLE = YES; 352 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 353 | MTL_ENABLE_DEBUG_INFO = NO; 354 | SDKROOT = iphoneos; 355 | TARGETED_DEVICE_FAMILY = "1,2"; 356 | VALIDATE_PRODUCT = YES; 357 | VERSIONING_SYSTEM = "apple-generic"; 358 | VERSION_INFO_PREFIX = ""; 359 | }; 360 | name = Release; 361 | }; 362 | CB0005531C76D26000FC3E1A /* Debug */ = { 363 | isa = XCBuildConfiguration; 364 | buildSettings = { 365 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 366 | DEFINES_MODULE = YES; 367 | DYLIB_COMPATIBILITY_VERSION = 1; 368 | DYLIB_CURRENT_VERSION = 1; 369 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 370 | INFOPLIST_FILE = SuperLogger/Info.plist; 371 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 372 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 373 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 374 | PRODUCT_BUNDLE_IDENTIFIER = com.yourtion.SuperLogger; 375 | PRODUCT_NAME = "$(TARGET_NAME)"; 376 | SKIP_INSTALL = YES; 377 | }; 378 | name = Debug; 379 | }; 380 | CB0005541C76D26000FC3E1A /* Release */ = { 381 | isa = XCBuildConfiguration; 382 | buildSettings = { 383 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 384 | DEFINES_MODULE = YES; 385 | DYLIB_COMPATIBILITY_VERSION = 1; 386 | DYLIB_CURRENT_VERSION = 1; 387 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 388 | INFOPLIST_FILE = SuperLogger/Info.plist; 389 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 390 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 391 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 392 | PRODUCT_BUNDLE_IDENTIFIER = com.yourtion.SuperLogger; 393 | PRODUCT_NAME = "$(TARGET_NAME)"; 394 | SKIP_INSTALL = YES; 395 | }; 396 | name = Release; 397 | }; 398 | CB0005561C76D26000FC3E1A /* Debug */ = { 399 | isa = XCBuildConfiguration; 400 | buildSettings = { 401 | INFOPLIST_FILE = SuperLoggerTests/Info.plist; 402 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 403 | PRODUCT_BUNDLE_IDENTIFIER = com.yourtion.SuperLoggerTests; 404 | PRODUCT_NAME = "$(TARGET_NAME)"; 405 | }; 406 | name = Debug; 407 | }; 408 | CB0005571C76D26000FC3E1A /* Release */ = { 409 | isa = XCBuildConfiguration; 410 | buildSettings = { 411 | INFOPLIST_FILE = SuperLoggerTests/Info.plist; 412 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 413 | PRODUCT_BUNDLE_IDENTIFIER = com.yourtion.SuperLoggerTests; 414 | PRODUCT_NAME = "$(TARGET_NAME)"; 415 | }; 416 | name = Release; 417 | }; 418 | /* End XCBuildConfiguration section */ 419 | 420 | /* Begin XCConfigurationList section */ 421 | CB0005381C76D26000FC3E1A /* Build configuration list for PBXProject "SuperLogger" */ = { 422 | isa = XCConfigurationList; 423 | buildConfigurations = ( 424 | CB0005501C76D26000FC3E1A /* Debug */, 425 | CB0005511C76D26000FC3E1A /* Release */, 426 | ); 427 | defaultConfigurationIsVisible = 0; 428 | defaultConfigurationName = Release; 429 | }; 430 | CB0005521C76D26000FC3E1A /* Build configuration list for PBXNativeTarget "SuperLogger" */ = { 431 | isa = XCConfigurationList; 432 | buildConfigurations = ( 433 | CB0005531C76D26000FC3E1A /* Debug */, 434 | CB0005541C76D26000FC3E1A /* Release */, 435 | ); 436 | defaultConfigurationIsVisible = 0; 437 | defaultConfigurationName = Release; 438 | }; 439 | CB0005551C76D26000FC3E1A /* Build configuration list for PBXNativeTarget "SuperLoggerTests" */ = { 440 | isa = XCConfigurationList; 441 | buildConfigurations = ( 442 | CB0005561C76D26000FC3E1A /* Debug */, 443 | CB0005571C76D26000FC3E1A /* Release */, 444 | ); 445 | defaultConfigurationIsVisible = 0; 446 | defaultConfigurationName = Release; 447 | }; 448 | /* End XCConfigurationList section */ 449 | }; 450 | rootObject = CB0005351C76D26000FC3E1A /* Project object */; 451 | } 452 | -------------------------------------------------------------------------------- /SuperLogger.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SuperLogger.xcodeproj/xcshareddata/xcschemes/SuperLogger.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 34 | 40 | 41 | 42 | 43 | 44 | 50 | 51 | 52 | 53 | 54 | 55 | 65 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 84 | 90 | 91 | 92 | 93 | 95 | 96 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /SuperLogger.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /SuperLogger/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /SuperLogger/Resources/SuperLogger.bundle/Base.lproj/SLLocalizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/SuperLogger/10d37b4aa9b321532418e4fd93e5b7b99284d1e8/SuperLogger/Resources/SuperLogger.bundle/Base.lproj/SLLocalizable.strings -------------------------------------------------------------------------------- /SuperLogger/Resources/SuperLogger.bundle/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleInfoDictionaryVersion 6 | 6.0 7 | StringsTable 8 | SLLocalizable 9 | CFBundleDevelopmentRegion 10 | en 11 | CFBundleIdentifier 12 | SuperLogger 13 | CFBundleName 14 | SuperLogger 15 | CFBundleVersion 16 | 1.0.0 17 | 18 | 19 | -------------------------------------------------------------------------------- /SuperLogger/Resources/SuperLogger.bundle/de.lproj/SLLocalizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/SuperLogger/10d37b4aa9b321532418e4fd93e5b7b99284d1e8/SuperLogger/Resources/SuperLogger.bundle/de.lproj/SLLocalizable.strings -------------------------------------------------------------------------------- /SuperLogger/Resources/SuperLogger.bundle/en.lproj/SLLocalizable.strings: -------------------------------------------------------------------------------- 1 | /* 2 | Localizable.strings 3 | Pods 4 | 5 | Created by t.may on 03/02/15. 6 | 7 | */ 8 | "SL_LogList" = "Log file list"; 9 | "SL_Back" = "Back"; 10 | "SL_Clean" = "Clean"; 11 | "SL_Cancel" = "Cancel"; 12 | "SL_Preview" = "Preview"; 13 | "SL_SendViaMail" = "Send via Email"; 14 | "SL_Delete" = "Delete"; 15 | "SL_Send" = "Send"; 16 | "SL_Star" = "Star"; 17 | "SL_Unstar" = "UnStar"; 18 | -------------------------------------------------------------------------------- /SuperLogger/Resources/SuperLogger.bundle/pl-PL.lproj/SLLocalizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/SuperLogger/10d37b4aa9b321532418e4fd93e5b7b99284d1e8/SuperLogger/Resources/SuperLogger.bundle/pl-PL.lproj/SLLocalizable.strings -------------------------------------------------------------------------------- /SuperLogger/Resources/SuperLogger.bundle/zh_CN.lproj/SLLocalizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/SuperLogger/10d37b4aa9b321532418e4fd93e5b7b99284d1e8/SuperLogger/Resources/SuperLogger.bundle/zh_CN.lproj/SLLocalizable.strings -------------------------------------------------------------------------------- /SuperLogger/SuperLogerListView.h: -------------------------------------------------------------------------------- 1 | // 2 | // SuperLogerListViewTableViewController.h 3 | // LogToFileDemo 4 | // 5 | // Created by YourtionGuo on 12/23/14. 6 | // Copyright (c) 2014 GYX. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SuperLogerListView : UITableViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /SuperLogger/SuperLogerListView.m: -------------------------------------------------------------------------------- 1 | // 2 | // SuperLogerListViewTableViewController.m 3 | // LogToFileDemo 4 | // 5 | // Created by YourtionGuo on 12/23/14. 6 | // Copyright (c) 2014 GYX. All rights reserved. 7 | // 8 | 9 | #import "SuperLogerListView.h" 10 | #import "SuperLogger.h" 11 | #import 12 | #import "SuperLoggerPreviewView.h" 13 | 14 | @interface SuperLogerListView () 15 | @property(strong,nonatomic) NSArray *fileList; 16 | @property (strong) UINavigationBar* navigationBar; 17 | @property (strong, nonatomic) NSString *tempFilename; 18 | @end 19 | 20 | @implementation SuperLogerListView 21 | 22 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 23 | { 24 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 25 | return self; 26 | } 27 | 28 | -(void)layoutNavigationBar 29 | { 30 | self.navigationBar.frame = CGRectMake(0, self.tableView.contentOffset.y, self.tableView.frame.size.width, self.topLayoutGuide.length + 44); 31 | self.tableView.contentInset = UIEdgeInsetsMake(self.navigationBar.frame.size.height, 0, 0, 0); 32 | } 33 | 34 | -(void)scrollViewDidScroll:(UIScrollView *)scrollView 35 | { 36 | [self layoutNavigationBar]; 37 | } 38 | 39 | -(void)viewDidLayoutSubviews 40 | { 41 | [super viewDidLayoutSubviews]; 42 | [self layoutNavigationBar]; 43 | } 44 | 45 | - (void)loadView 46 | { 47 | CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame]; 48 | self.tableView = [[UITableView alloc]initWithFrame:applicationFrame]; 49 | self.view.backgroundColor=[UIColor whiteColor]; 50 | } 51 | 52 | - (void)viewDidLoad 53 | { 54 | [super viewDidLoad]; 55 | 56 | self.fileList = [[SuperLogger sharedInstance]getLogList]; 57 | self.navigationItem.title = SLLocalizedString( @"SL_LogList", @"Log file list"); 58 | self.navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectZero]; 59 | [self.view addSubview:_navigationBar]; 60 | [self.navigationBar pushNavigationItem:self.navigationItem animated:NO]; 61 | UIBarButtonItem *backBtn=[[UIBarButtonItem alloc] initWithTitle:SLLocalizedString( @"SL_Back", @"Back") style:UIBarButtonItemStylePlain target:self action:@selector(done)]; 62 | [self.navigationItem setLeftBarButtonItem:backBtn]; 63 | if ([SuperLogger sharedInstance].enableDelete){ 64 | UIBarButtonItem *cleanBtn=[[UIBarButtonItem alloc] initWithTitle:SLLocalizedString( @"SL_Clean", @"Clean") style:UIBarButtonItemStylePlain target:self action:@selector(clean)]; 65 | [self.navigationItem setRightBarButtonItem:cleanBtn]; 66 | } 67 | } 68 | 69 | -(void)done 70 | { 71 | [self dismissViewControllerAnimated:YES completion:nil]; 72 | } 73 | 74 | -(void)clean 75 | { 76 | [[SuperLogger sharedInstance]cleanLogs]; 77 | self.fileList = nil; 78 | self.fileList = [[SuperLogger sharedInstance]getLogList]; 79 | [self.tableView reloadData]; 80 | } 81 | 82 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 83 | { 84 | return 1; 85 | } 86 | 87 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 88 | { 89 | return self.fileList.count; 90 | } 91 | 92 | 93 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 94 | { 95 | UITableViewCell *cell = [[UITableViewCell alloc]init]; 96 | cell.textLabel.text = self.fileList[indexPath.row]; 97 | if ([[SuperLogger sharedInstance] isStaredWithFilename:self.fileList[indexPath.row]]) { 98 | if ([SuperLogger sharedInstance].enableStar){ 99 | cell.accessoryType = UITableViewCellAccessoryDetailButton; 100 | } 101 | } 102 | return cell; 103 | } 104 | 105 | 106 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 107 | { 108 | UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 109 | _tempFilename = _fileList[indexPath.row]; 110 | [self exportTapped:cell]; 111 | } 112 | 113 | /** 114 | * Shows Alert controller after user tapped on a log file 115 | * 116 | * @param sender object that triggered the alert controller 117 | */ 118 | - (void)exportTapped:(id)sender 119 | { 120 | UITableViewCell *cell = (UITableViewCell *) sender; 121 | 122 | @try { 123 | NSBundle* myBundle; 124 | NSString *path = [[NSBundle mainBundle] pathForResource:@"SuperLogger" ofType:@"bundle"]; 125 | myBundle = [NSBundle bundleWithPath:path]; 126 | 127 | UIAlertController * alertController = [UIAlertController alertControllerWithTitle:cell.textLabel.text message:nil preferredStyle:UIAlertControllerStyleActionSheet]; 128 | UIPopoverPresentationController *popover = alertController.popoverPresentationController; 129 | if (popover) { 130 | alertController = [UIAlertController alertControllerWithTitle:cell.textLabel.text message:nil preferredStyle:UIAlertControllerStyleAlert]; 131 | popover.sourceView = self.view; 132 | popover.sourceRect = CGRectMake((CGRectGetWidth(popover.sourceView.bounds)-2)*0.5f, (CGRectGetHeight(popover.sourceView.bounds)-2)*0.5f, 2, 2);// Show in center. 133 | } 134 | 135 | if ([SuperLogger sharedInstance].enableStar){ 136 | [alertController addAction:[self getAlertActionEnableStar]]; 137 | } 138 | 139 | if ([SuperLogger sharedInstance].enablePreview){ 140 | 141 | [alertController addAction:[self getAlertActionEnablePreview]]; 142 | } 143 | if ([SuperLogger sharedInstance].enableMail){ 144 | 145 | [alertController addAction:[self getAlertActionEnableMail]]; 146 | } 147 | 148 | if ([SuperLogger sharedInstance].enableDelete) { 149 | [alertController addAction:[self getAlertActionEnableDelete]]; 150 | } 151 | 152 | UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:SLLocalizedString( @"SL_Cancel", @"Cancel") style:UIAlertActionStyleDefault handler:Nil]; 153 | [alertController addAction:cancelAction]; 154 | 155 | dispatch_async(dispatch_get_main_queue(), ^(void){ 156 | [self presentViewController:alertController animated:YES completion:nil]; 157 | }); 158 | 159 | } 160 | @catch (NSException * e) 161 | { NSLog(@"Exception: %@", e); } 162 | } 163 | 164 | - (UIAlertAction *)getAlertActionEnableStar { 165 | NSString *isStar = [[SuperLogger sharedInstance] isStaredWithFilename:_tempFilename] ? SLLocalizedString(@"SL_Unstar",@"Unstar"): SLLocalizedString( @"SL_Star", @"Star"); 166 | 167 | UIAlertAction * starAction = [UIAlertAction actionWithTitle:isStar style:UIAlertActionStyleDefault handler:^(UIAlertAction * action){ 168 | [[SuperLogger sharedInstance]starWithFilename:_tempFilename]; 169 | self.fileList = nil; 170 | self.fileList = [[SuperLogger sharedInstance]getLogList]; 171 | [self.tableView reloadData]; 172 | }]; 173 | 174 | return starAction; 175 | } 176 | 177 | - (UIAlertAction *)getAlertActionEnablePreview { 178 | UIAlertAction * previewAction = [UIAlertAction actionWithTitle:SLLocalizedString( @"SL_Preview", @"Preview") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { 179 | 180 | SuperLoggerPreviewView *pre = [[SuperLoggerPreviewView alloc]init]; 181 | pre.logData = [[SuperLogger sharedInstance] getDataWithFilename:_tempFilename]; 182 | pre.logFilename = _tempFilename; 183 | dispatch_async(dispatch_get_main_queue(), ^(void){ 184 | [self presentViewController:pre animated:YES completion:nil]; 185 | }); 186 | 187 | }]; 188 | return previewAction; 189 | } 190 | 191 | - (UIAlertAction *)getAlertActionEnableMail { 192 | UIAlertAction * mailAction = [UIAlertAction actionWithTitle:SLLocalizedString( @"SL_SendViaMail", @"Send via Email") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){ 193 | [[NSOperationQueue mainQueue] addOperationWithBlock:^{ 194 | SuperLogger *logger = [SuperLogger sharedInstance]; 195 | NSData *tempData = [logger getDataWithFilename:_tempFilename]; 196 | if (tempData != nil) { 197 | MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; 198 | [picker setSubject:logger.mailTitle]; 199 | [picker setToRecipients:logger.mailRecipients]; 200 | [picker addAttachmentData:tempData mimeType:@"application/text" fileName:_tempFilename]; 201 | [picker setToRecipients:@[]]; 202 | [picker setMessageBody:logger.mailContect isHTML:NO]; 203 | [picker setMailComposeDelegate:self]; 204 | dispatch_async(dispatch_get_main_queue(), ^(void){ 205 | @try { 206 | [self presentViewController:picker animated:YES completion:nil]; 207 | } 208 | @catch (NSException * e) 209 | { NSLog(@"Exception: %@", e); } 210 | }); 211 | } 212 | }]; 213 | 214 | }]; 215 | return mailAction; 216 | } 217 | 218 | - (UIAlertAction *)getAlertActionEnableDelete { 219 | UIAlertAction * deleteAction = [UIAlertAction actionWithTitle:SLLocalizedString( @"SL_Delete", @"Delete") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action){ 220 | [[SuperLogger sharedInstance]deleteLogWithFilename:_tempFilename]; 221 | self.fileList = nil; 222 | self.fileList = [[SuperLogger sharedInstance]getLogList]; 223 | [self.tableView reloadData]; 224 | }]; 225 | return deleteAction; 226 | } 227 | 228 | - (void)mailComposeController:(MFMailComposeViewController *)controller 229 | didFinishWithResult:(MFMailComposeResult)result 230 | error:(NSError *)error 231 | { 232 | [self dismissViewControllerAnimated:YES completion:nil]; 233 | } 234 | 235 | @end 236 | -------------------------------------------------------------------------------- /SuperLogger/SuperLogger.h: -------------------------------------------------------------------------------- 1 | // 2 | // SuperLogger.h 3 | // LogToFileDemo 4 | // 5 | // Created by YourtionGuo on 12/23/14. 6 | // Copyright (c) 2014 GYX. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | #define SLLocalizedString(key, comment) [[SuperLogger sharedInstance].bundle localizedStringForKey:(key) value:comment table:@"SLLocalizable"] 13 | 14 | 15 | @interface SuperLogger : NSObject 16 | @property(strong, nonatomic) NSString *mailTitle; 17 | @property(strong, nonatomic) NSString *mailContect; 18 | @property(strong, nonatomic) NSArray *mailRecipients; 19 | @property(assign,nonatomic) BOOL enableStar; 20 | @property(assign,nonatomic) BOOL enablePreview; 21 | @property(assign,nonatomic) BOOL enableMail; 22 | @property(assign,nonatomic) BOOL enableDelete; 23 | @property(strong, nonatomic) NSBundle *bundle; 24 | 25 | /** 26 | * SuperLogger sharedInstance 27 | * 28 | * @return SuperLogger sharedInstance 29 | */ 30 | + (SuperLogger *)sharedInstance; 31 | 32 | /** 33 | * Start redirectNSLogToDocumentFolder 34 | */ 35 | - (void)redirectNSLogToDocumentFolder; 36 | 37 | /** 38 | * Get all logfile 39 | * 40 | * @return logfile list Array 41 | */ 42 | - (NSArray *)getLogList; 43 | /** 44 | * Get SuperLogerListView 45 | * 46 | * @return UITableView logger listview 47 | */ 48 | - (id)getListView; 49 | 50 | /** 51 | * Star with filename 52 | * 53 | * @param filename filename log filename 54 | * 55 | * @return Is star succee 56 | */ 57 | - (BOOL)starWithFilename:(NSString *)filename; 58 | /** 59 | * Is file stared 60 | * 61 | * @param filename log filename 62 | * 63 | * @return is file stared 64 | */ 65 | - (BOOL)isStaredWithFilename:(NSString *)filename; 66 | 67 | /** 68 | * Clean all logs 69 | */ 70 | - (void)cleanLogs; 71 | 72 | /** 73 | * Delete crash log 74 | */ 75 | -(void)deleteCrash; 76 | 77 | /** 78 | * Clean and keep numbers of logs 79 | * 80 | * @param keepMaxLogs Number of logs you want to keep 81 | * @param starts Clean starts logs ? 82 | * 83 | * @return Succeed to clean 84 | */ 85 | -(BOOL)cleanLogsByKeeping:(int)keepMaxLogs deleteStarts:(BOOL)starts; 86 | 87 | /** 88 | * Clean logs befor date 89 | * 90 | * @param before The date you want to clean logs befor 91 | * @param starts Clean starts logs ? 92 | * 93 | * @return Succeed to clean 94 | */ 95 | -(BOOL)cleanLogsBefore:(NSDate *)before deleteStarts:(BOOL)starts; 96 | 97 | /** 98 | * Get logfile's NSData with filename 99 | * 100 | * @param filename log filename 101 | * 102 | * @return logfile content data 103 | */ 104 | - (NSData *)getDataWithFilename:(NSString *)filename; 105 | 106 | /** 107 | * Delete Logfile With Filename 108 | * 109 | * @param filename log filename 110 | */ 111 | - (void)deleteLogWithFilename:(NSString *)filename; 112 | @end 113 | -------------------------------------------------------------------------------- /SuperLogger/SuperLogger.m: -------------------------------------------------------------------------------- 1 | // 2 | // SuperLogger.m 3 | // LogToFileDemo 4 | // 5 | // Created by YourtionGuo on 12/23/14. 6 | // Copyright (c) 2014 GYX. All rights reserved. 7 | // 8 | 9 | #import "SuperLogger.h" 10 | #import "SuperLoggerFunctions.h" 11 | #import "SuperLogerListView.h" 12 | 13 | #define STARLIST @"SuperLogger_star" 14 | 15 | @interface SuperLogger() 16 | @property(strong, nonatomic) NSUserDefaults *userDefaults; 17 | @property(strong, nonatomic) NSMutableArray *starList; 18 | @property(strong, nonatomic) NSString *logDirectory; 19 | @property(strong, nonatomic) NSString *logFilename; 20 | @property(strong, nonatomic) NSString *logFileFormat; 21 | @end 22 | 23 | @implementation SuperLogger 24 | { 25 | NSString *crash; 26 | } 27 | 28 | - (instancetype)init 29 | { 30 | @throw [NSException exceptionWithName:@"Do not init SuperLogger" 31 | reason:@"You should use [SuperLogger sharedInstance]" 32 | userInfo:nil]; 33 | return nil; 34 | } 35 | 36 | + (NSBundle *)getBundle 37 | { 38 | NSBundle *bundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"SuperLogger" ofType:@"bundle"]]; 39 | if (!bundle) { 40 | bundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[SuperLogger self]] pathForResource:@"SuperLogger" ofType:@"bundle"]]; 41 | } 42 | return bundle; 43 | } 44 | 45 | 46 | /** 47 | * SuperLogger sharedInstance 48 | */ 49 | + (SuperLogger *)sharedInstance 50 | { 51 | static SuperLogger*_sharedInstance = nil; 52 | static dispatch_once_t oncePredicate; 53 | dispatch_once(&oncePredicate, ^{ 54 | _sharedInstance = [[SuperLogger alloc] initPrivate]; 55 | _sharedInstance.enableStar =YES; //Default: Allow Star 56 | _sharedInstance.enableDelete =YES; 57 | _sharedInstance.enableMail=YES; 58 | _sharedInstance.enablePreview=YES; 59 | _sharedInstance.bundle = [SuperLogger getBundle]; 60 | }); 61 | return _sharedInstance; 62 | } 63 | 64 | /** 65 | * SuperLogger initPrivate (set logDirectory) 66 | */ 67 | - (instancetype)initPrivate 68 | { 69 | self = [super init]; 70 | if (self) { 71 | self.userDefaults = [NSUserDefaults standardUserDefaults]; 72 | if ([self.userDefaults objectForKey:STARLIST]) { 73 | self.starList = [[NSMutableArray alloc]initWithArray:[self.userDefaults objectForKey:STARLIST]]; 74 | }else{ 75 | self.starList = [[NSMutableArray alloc]init]; 76 | } 77 | //将NSlog打印信息保存到Document目录下的Log文件夹下 78 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 79 | self.logDirectory = [paths[0] stringByAppendingPathComponent:@"Log"]; 80 | self.logFileFormat = @"yyyy-MM-dd_HH:mm:ss"; 81 | } 82 | return self; 83 | } 84 | 85 | /** 86 | * Start redirectNSLogToDocumentFolder 87 | */ 88 | -(void)redirectNSLogToDocumentFolder 89 | { 90 | if(isatty(STDOUT_FILENO)) { 91 | return; 92 | } 93 | 94 | UIDevice *device = [UIDevice currentDevice]; 95 | if([[device model] hasSuffix:@"Simulator"]){ 96 | return; 97 | } 98 | 99 | NSFileManager *fileManager = [NSFileManager defaultManager]; 100 | 101 | if (![SuperLoggerFunctions isFileExistAtPath:_logDirectory]) { 102 | [fileManager createDirectoryAtPath:_logDirectory withIntermediateDirectories:YES attributes:nil error:nil]; 103 | } 104 | 105 | NSString *dateStr = [SuperLoggerFunctions getDateTimeStringWithFormat:_logFileFormat]; 106 | self.logFilename = [NSString stringWithFormat:@"%@.log",dateStr]; 107 | NSString *logFilePath = [_logDirectory stringByAppendingPathComponent:_logFilename]; 108 | 109 | freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding], "a+", stdout); 110 | freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding], "a+", stderr); 111 | 112 | NSSetUncaughtExceptionHandler (&UncaughtExceptionHandler); 113 | } 114 | 115 | void UncaughtExceptionHandler(NSException* exception) 116 | { 117 | NSString *name = [exception name]; 118 | NSString *reason = [exception reason]; 119 | NSArray *symbols = [exception callStackSymbols]; // 异常发生时的调用栈 120 | NSMutableString *strSymbols = [ [ NSMutableString alloc ] init ]; //将调用栈拼成输出日志的字符串 121 | for (NSString *item in symbols){ 122 | [strSymbols appendString: item]; 123 | [strSymbols appendString: @"\r\n"]; 124 | } 125 | 126 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 127 | NSString *logDirectory = [paths[0] stringByAppendingPathComponent:@"Log"]; 128 | 129 | NSFileManager *fileManager = [NSFileManager defaultManager]; 130 | if (![fileManager fileExistsAtPath:logDirectory]) { 131 | [fileManager createDirectoryAtPath:logDirectory withIntermediateDirectories:YES attributes:nil error:nil]; 132 | } 133 | 134 | NSString *logFilePath = [logDirectory stringByAppendingPathComponent:@"CrashLog.log"]; 135 | NSString *dateStr = [SuperLoggerFunctions getDateTimeStringWithFormat:@"yyyy-MM-dd HH:mm:ss"]; 136 | 137 | NSString *crashString = [NSString stringWithFormat:@"<- %@ ->[ Uncaught Exception ]\r\nName: %@, Reason: %@\r\n[ Fe Symbols Start ]\r\n%@[ Fe Symbols End ]\r\n\r\n", dateStr, name, reason, strSymbols]; 138 | 139 | if (![fileManager fileExistsAtPath:logFilePath]) { 140 | [crashString writeToFile:logFilePath atomically:YES encoding:NSUTF8StringEncoding error:nil]; 141 | }else{ 142 | NSFileHandle *outFile = [NSFileHandle fileHandleForWritingAtPath:logFilePath]; 143 | [outFile seekToEndOfFile]; 144 | [outFile writeData:[crashString dataUsingEncoding:NSUTF8StringEncoding]]; 145 | [outFile closeFile]; 146 | } 147 | } 148 | 149 | /** 150 | * Get all logfile 151 | */ 152 | -(NSArray *)getLogList 153 | { 154 | return [SuperLoggerFunctions getFilenamelistOfType:@"log" fromDirPath:_logDirectory]; 155 | } 156 | 157 | /** 158 | * Get SuperLogerListView 159 | */ 160 | -(id)getListView 161 | { 162 | return [[SuperLogerListView alloc]init]; 163 | } 164 | 165 | /** 166 | * Star with filename 167 | */ 168 | -(BOOL)starWithFilename:(NSString *)filename 169 | { 170 | if ([self.starList containsObject:filename]) { 171 | [self.starList removeObject:filename]; 172 | }else{ 173 | [self.starList addObject:filename]; 174 | } 175 | [self.userDefaults setObject:self.starList forKey:STARLIST]; 176 | return [self.userDefaults synchronize]; 177 | } 178 | 179 | /** 180 | * Is file stared 181 | */ 182 | -(BOOL)isStaredWithFilename:(NSString *)filename 183 | { 184 | return [self.starList containsObject:filename]; 185 | } 186 | 187 | /** 188 | * Clean all logs 189 | */ 190 | -(void)cleanLogs 191 | { 192 | NSArray *files = [SuperLoggerFunctions getFilenamelistOfType:@"log" fromDirPath:_logDirectory]; 193 | for (NSString *file in files) { 194 | if (![file isEqualToString: @"CrashLog.log"] && 195 | ![file isEqualToString: self.logFilename]) { 196 | [self deleteLogWithFilename:file]; 197 | } 198 | } 199 | } 200 | 201 | /** 202 | * Delete crash logs 203 | */ 204 | -(void)deleteCrash 205 | { 206 | [self deleteLogWithFilename:@"CrashLog.log"]; 207 | } 208 | 209 | -(BOOL)cleanLogsByKeeping:(int)keepMaxLogs deleteStarts:(BOOL)starts 210 | { 211 | NSMutableArray *logs = [[NSMutableArray alloc]initWithArray:[self getLogList]]; 212 | [logs removeObject:@"CrashLog.log"]; 213 | if (!starts) { 214 | for (NSString *file in _starList) { 215 | [logs removeObject:file]; 216 | } 217 | } 218 | if (keepMaxLogs > 1 && [logs count] > keepMaxLogs) { 219 | [logs removeObjectsInRange:NSMakeRange(0, keepMaxLogs)]; 220 | for (NSString *file in logs) { 221 | [self deleteLogWithFilename:file]; 222 | } 223 | }else{ 224 | return NO; 225 | } 226 | return YES; 227 | } 228 | 229 | -(BOOL)cleanLogsBefore:(NSDate *)before deleteStarts:(BOOL)starts 230 | { 231 | NSMutableArray *logs = [[NSMutableArray alloc]initWithArray:[self getLogList]]; 232 | [logs removeObject:@"CrashLog.log"]; 233 | if (!starts) { 234 | for (NSString *file in _starList) { 235 | [logs removeObject:file]; 236 | } 237 | } 238 | if (before) { 239 | for (NSString *file in logs) { 240 | NSDate *fileDate = [SuperLoggerFunctions getDateTimeFromString:[file substringToIndex:[file length]-4] withFormat:_logFileFormat]; 241 | if ([fileDate timeIntervalSinceDate:before] < 0 && ![file isEqualToString: self.logFilename]) { 242 | [self deleteLogWithFilename:file]; 243 | } 244 | } 245 | }else{ 246 | return NO; 247 | } 248 | return YES; 249 | } 250 | 251 | /** 252 | * Get logfile's NSData with filename 253 | */ 254 | -(NSData *)getDataWithFilename:(NSString *)filename 255 | { 256 | NSString *logFilePath = [_logDirectory stringByAppendingPathComponent:filename]; 257 | return [NSData dataWithContentsOfFile:logFilePath]; 258 | } 259 | 260 | /** 261 | * Delete Logfile With Filename 262 | */ 263 | -(void)deleteLogWithFilename:(NSString *)filename 264 | { 265 | NSString *logFilePath = [_logDirectory stringByAppendingPathComponent:filename]; 266 | NSFileManager *fileManager = [NSFileManager defaultManager]; 267 | [fileManager removeItemAtPath:logFilePath error:NULL]; 268 | } 269 | 270 | @end 271 | -------------------------------------------------------------------------------- /SuperLogger/SuperLoggerFunctions.h: -------------------------------------------------------------------------------- 1 | // 2 | // SuperLoggerFunctions.h 3 | // LogToFileDemo 4 | // 5 | // Created by YourtionGuo on 12/23/14. 6 | // Copyright (c) 2014 GYX. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SuperLoggerFunctions : NSObject 12 | 13 | /** 14 | * getDateTimeStringWithFormat 15 | * 16 | * @param format like "yyyy-MM-dd HH:mm:ss" 17 | * 18 | * @return NSString like 2014-12-02 12:59:30 19 | */ 20 | +(NSString *)getDateTimeStringWithFormat:(NSString *)format; 21 | 22 | /** 23 | * getDateTimeFromString 24 | * 25 | * @param string like "2015-01-12 12:16:11" 26 | * @param format like "yyyy-MM-dd HH:mm:ss" 27 | * 28 | * @return NSDate from string 29 | */ 30 | +(NSDate *)getDateTimeFromString:(NSString *)string withFormat:(NSString *)format; 31 | 32 | /** 33 | * getFilenamelistOfType 34 | * 35 | * @param type fileTile like @"log" 36 | * @param dirPath filePath 37 | * 38 | * @return filename array 39 | */ 40 | +(NSArray *)getFilenamelistOfType:(NSString *)type fromDirPath:(NSString *)dirPath; 41 | 42 | /** 43 | * isFileExistAtPath 44 | * 45 | * @param fileFullPath fileFullPath 46 | * 47 | * @return is File Exist 48 | */ 49 | +(BOOL)isFileExistAtPath:(NSString*)fileFullPath; 50 | @end 51 | -------------------------------------------------------------------------------- /SuperLogger/SuperLoggerFunctions.m: -------------------------------------------------------------------------------- 1 | // 2 | // SuperLoggerFunctions.m 3 | // LogToFileDemo 4 | // 5 | // Created by YourtionGuo on 12/23/14. 6 | // Copyright (c) 2014 GYX. All rights reserved. 7 | // 8 | 9 | #import "SuperLoggerFunctions.h" 10 | 11 | @implementation SuperLoggerFunctions 12 | /** 13 | * getDateTimeStringWithFormat 14 | */ 15 | +(NSString *)getDateTimeStringWithFormat:(NSString *)format 16 | { 17 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 18 | [formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:[NSLocale currentLocale ].localeIdentifier]]; 19 | [formatter setDateFormat:format]; 20 | return [formatter stringFromDate:[NSDate date]]; 21 | } 22 | 23 | /** 24 | * getDateTimeFromString 25 | */ 26 | +(NSDate *)getDateTimeFromString:(NSString *)string withFormat:(NSString *)format 27 | { 28 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 29 | [formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:[NSLocale currentLocale ].localeIdentifier]]; 30 | [formatter setDateFormat:format]; 31 | NSDate *date = [[NSDate alloc] init]; 32 | date = [formatter dateFromString:string]; 33 | return date; 34 | } 35 | 36 | /** 37 | * getFilenamelistOfType 38 | */ 39 | +(NSArray *)getFilenamelistOfType:(NSString *)type fromDirPath:(NSString *)dirPath 40 | { 41 | NSMutableArray *filenamelist = [NSMutableArray arrayWithCapacity:10]; 42 | NSArray *tmplist = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:dirPath error:nil]; 43 | 44 | for (NSString *filename in tmplist) { 45 | NSString *fullpath = [dirPath stringByAppendingPathComponent:filename]; 46 | if ([SuperLoggerFunctions isFileExistAtPath:fullpath]) { 47 | if ([[filename pathExtension] isEqualToString:type]) { 48 | [filenamelist addObject:filename]; 49 | } 50 | } 51 | } 52 | NSArray *sortedList = [filenamelist sortedArrayUsingComparator:^NSComparisonResult(NSString *str1, NSString *str2) { 53 | NSString *fileName1 = [str1 lastPathComponent]; 54 | NSString *fileName2 = [str2 lastPathComponent]; 55 | NSStringCompareOptions options = NSCaseInsensitiveSearch | NSNumericSearch; 56 | return [fileName2 compare:fileName1 options:options]; 57 | }]; 58 | return sortedList; 59 | } 60 | 61 | /** 62 | * isFileExistAtPath 63 | */ 64 | +(BOOL)isFileExistAtPath:(NSString*)fileFullPath 65 | { 66 | return [[NSFileManager defaultManager] fileExistsAtPath:fileFullPath]; 67 | } 68 | @end 69 | -------------------------------------------------------------------------------- /SuperLogger/SuperLoggerPreviewView.h: -------------------------------------------------------------------------------- 1 | // 2 | // SuperLoggerPreviewView.h 3 | // SuperLoggerDemo 4 | // 5 | // Created by YourtionGuo on 12/24/14. 6 | // Copyright (c) 2014 GYX. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SuperLoggerPreviewView : UIViewController 12 | @property(strong, nonatomic) NSData *logData; 13 | @property(strong, nonatomic) NSString *logFilename; 14 | @end 15 | -------------------------------------------------------------------------------- /SuperLogger/SuperLoggerPreviewView.m: -------------------------------------------------------------------------------- 1 | // 2 | // SuperLoggerPreviewView.m 3 | // SuperLoggerDemo 4 | // 5 | // Created by YourtionGuo on 12/24/14. 6 | // Copyright (c) 2014 GYX. All rights reserved. 7 | // 8 | 9 | #import "SuperLoggerPreviewView.h" 10 | #import 11 | #import "SuperLogger.h" 12 | 13 | @interface SuperLoggerPreviewView () 14 | @property (strong) UINavigationBar* navigationBar; 15 | @end 16 | 17 | @implementation SuperLoggerPreviewView 18 | 19 | -(void)layoutNavigationBar 20 | { 21 | self.navigationBar.frame = CGRectMake(0, 0, self.view.frame.size.width, self.topLayoutGuide.length + 44); 22 | } 23 | 24 | -(void)scrollViewDidScroll:(UIScrollView *)scrollView 25 | { 26 | [self layoutNavigationBar]; 27 | } 28 | 29 | -(void)viewDidLayoutSubviews 30 | { 31 | [super viewDidLayoutSubviews]; 32 | [self layoutNavigationBar]; 33 | } 34 | 35 | - (void)loadView 36 | { 37 | CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame]; 38 | self.view = [[UIView alloc]initWithFrame:applicationFrame]; 39 | self.view.backgroundColor=[UIColor whiteColor]; 40 | } 41 | 42 | - (void)viewDidLoad { 43 | [super viewDidLoad]; 44 | 45 | self.navigationItem.title = _logFilename; 46 | self.navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectZero]; 47 | [self.view addSubview:_navigationBar]; 48 | [self.navigationBar pushNavigationItem:self.navigationItem animated:NO]; 49 | UIBarButtonItem *backBtn=[[UIBarButtonItem alloc] initWithTitle: SLLocalizedString(@"SL_Back",@"Back") style:UIBarButtonItemStylePlain target:self action:@selector(done)]; 50 | [self.navigationItem setLeftBarButtonItem:backBtn]; 51 | UIBarButtonItem *sendBtn=[[UIBarButtonItem alloc] initWithTitle:SLLocalizedString(@"SL_Send",@"Send") style:UIBarButtonItemStylePlain target:self action:@selector(send)]; 52 | [self.navigationItem setRightBarButtonItem:sendBtn]; 53 | 54 | NSString* newStr = [[NSString alloc] initWithData:self.logData encoding:NSUTF8StringEncoding]; 55 | UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(0, 44+28, self.view.frame.size.width, self.view.frame.size.height -44)]; 56 | textView.tag = 999; 57 | textView.editable = NO; 58 | textView.text = newStr; 59 | [self.view addSubview:textView]; 60 | // Do any additional setup after loading the view. 61 | } 62 | 63 | -(void)done 64 | { 65 | [self dismissViewControllerAnimated:YES completion:nil]; 66 | } 67 | 68 | 69 | -(void)send 70 | { 71 | [[NSOperationQueue mainQueue] addOperationWithBlock:^{ 72 | SuperLogger *logger = [SuperLogger sharedInstance]; 73 | if (self.logData != nil) { 74 | MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; 75 | [picker setSubject:logger.mailTitle]; 76 | [picker setToRecipients:logger.mailRecipients]; 77 | [picker addAttachmentData:self.logData mimeType:@"application/text" fileName:_logFilename]; 78 | [picker setToRecipients:@[]]; 79 | [picker setMessageBody:logger.mailContect isHTML:NO]; 80 | [picker setMailComposeDelegate:self]; 81 | @try { 82 | [self presentViewController:picker animated:YES completion:nil]; 83 | } 84 | @catch (NSException * e) 85 | { NSLog(@"Exception: %@", e); } 86 | } 87 | }]; 88 | } 89 | 90 | - (void)mailComposeController:(MFMailComposeViewController *)controller 91 | didFinishWithResult:(MFMailComposeResult)result 92 | error:(NSError *)error 93 | { 94 | [self dismissViewControllerAnimated:YES completion:nil]; 95 | } 96 | 97 | @end 98 | -------------------------------------------------------------------------------- /SuperLoggerDemo/SuperLoggerDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | CBA60BFD1DD95C1F00F7ED51 /* SuperLogger.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CBEEB2641D3F70A000E3D8DC /* SuperLogger.framework */; }; 11 | CBA60BFE1DD95C1F00F7ED51 /* SuperLogger.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = CBEEB2641D3F70A000E3D8DC /* SuperLogger.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 12 | CBF026081A49AB8100F28BC0 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = CBF026071A49AB8100F28BC0 /* main.m */; }; 13 | CBF0260B1A49AB8100F28BC0 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = CBF0260A1A49AB8100F28BC0 /* AppDelegate.m */; }; 14 | CBF0260E1A49AB8100F28BC0 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = CBF0260D1A49AB8100F28BC0 /* ViewController.m */; }; 15 | CBF026111A49AB8100F28BC0 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CBF0260F1A49AB8100F28BC0 /* Main.storyboard */; }; 16 | CBF026131A49AB8100F28BC0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CBF026121A49AB8100F28BC0 /* Images.xcassets */; }; 17 | CBF026161A49AB8100F28BC0 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = CBF026141A49AB8100F28BC0 /* LaunchScreen.xib */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXCopyFilesBuildPhase section */ 21 | CBA60BFF1DD95C1F00F7ED51 /* Embed Frameworks */ = { 22 | isa = PBXCopyFilesBuildPhase; 23 | buildActionMask = 2147483647; 24 | dstPath = ""; 25 | dstSubfolderSpec = 10; 26 | files = ( 27 | CBA60BFE1DD95C1F00F7ED51 /* SuperLogger.framework in Embed Frameworks */, 28 | ); 29 | name = "Embed Frameworks"; 30 | runOnlyForDeploymentPostprocessing = 0; 31 | }; 32 | /* End PBXCopyFilesBuildPhase section */ 33 | 34 | /* Begin PBXFileReference section */ 35 | CBEEB2641D3F70A000E3D8DC /* SuperLogger.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SuperLogger.framework; path = "../../../../Library/Developer/Xcode/DerivedData/SuperLogger-eggsbqvxpkigpmdnsnkrutgjdszh/Build/Products/Debug-iphoneos/SuperLogger.framework"; sourceTree = ""; }; 36 | CBF026021A49AB8100F28BC0 /* SuperLoggerDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SuperLoggerDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | CBF026061A49AB8100F28BC0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 38 | CBF026071A49AB8100F28BC0 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 39 | CBF026091A49AB8100F28BC0 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 40 | CBF0260A1A49AB8100F28BC0 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 41 | CBF0260C1A49AB8100F28BC0 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 42 | CBF0260D1A49AB8100F28BC0 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 43 | CBF026101A49AB8100F28BC0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 44 | CBF026121A49AB8100F28BC0 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 45 | CBF026151A49AB8100F28BC0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 46 | /* End PBXFileReference section */ 47 | 48 | /* Begin PBXFrameworksBuildPhase section */ 49 | CBF025FF1A49AB8100F28BC0 /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | CBA60BFD1DD95C1F00F7ED51 /* SuperLogger.framework in Frameworks */, 54 | ); 55 | runOnlyForDeploymentPostprocessing = 0; 56 | }; 57 | /* End PBXFrameworksBuildPhase section */ 58 | 59 | /* Begin PBXGroup section */ 60 | CBF025F91A49AB8100F28BC0 = { 61 | isa = PBXGroup; 62 | children = ( 63 | CBEEB2641D3F70A000E3D8DC /* SuperLogger.framework */, 64 | CBF026041A49AB8100F28BC0 /* SuperLoggerDemo */, 65 | CBF026031A49AB8100F28BC0 /* Products */, 66 | ); 67 | sourceTree = ""; 68 | }; 69 | CBF026031A49AB8100F28BC0 /* Products */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | CBF026021A49AB8100F28BC0 /* SuperLoggerDemo.app */, 73 | ); 74 | name = Products; 75 | sourceTree = ""; 76 | }; 77 | CBF026041A49AB8100F28BC0 /* SuperLoggerDemo */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | CBF026091A49AB8100F28BC0 /* AppDelegate.h */, 81 | CBF0260A1A49AB8100F28BC0 /* AppDelegate.m */, 82 | CBF0260C1A49AB8100F28BC0 /* ViewController.h */, 83 | CBF0260D1A49AB8100F28BC0 /* ViewController.m */, 84 | CBF0260F1A49AB8100F28BC0 /* Main.storyboard */, 85 | CBF026121A49AB8100F28BC0 /* Images.xcassets */, 86 | CBF026141A49AB8100F28BC0 /* LaunchScreen.xib */, 87 | CBF026051A49AB8100F28BC0 /* Supporting Files */, 88 | ); 89 | path = SuperLoggerDemo; 90 | sourceTree = ""; 91 | }; 92 | CBF026051A49AB8100F28BC0 /* Supporting Files */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | CBF026061A49AB8100F28BC0 /* Info.plist */, 96 | CBF026071A49AB8100F28BC0 /* main.m */, 97 | ); 98 | name = "Supporting Files"; 99 | sourceTree = ""; 100 | }; 101 | /* End PBXGroup section */ 102 | 103 | /* Begin PBXNativeTarget section */ 104 | CBF026011A49AB8100F28BC0 /* SuperLoggerDemo */ = { 105 | isa = PBXNativeTarget; 106 | buildConfigurationList = CBF026251A49AB8100F28BC0 /* Build configuration list for PBXNativeTarget "SuperLoggerDemo" */; 107 | buildPhases = ( 108 | CBF025FE1A49AB8100F28BC0 /* Sources */, 109 | CBF025FF1A49AB8100F28BC0 /* Frameworks */, 110 | CBF026001A49AB8100F28BC0 /* Resources */, 111 | CBA60BFF1DD95C1F00F7ED51 /* Embed Frameworks */, 112 | ); 113 | buildRules = ( 114 | ); 115 | dependencies = ( 116 | ); 117 | name = SuperLoggerDemo; 118 | productName = SuperLoggerDemo; 119 | productReference = CBF026021A49AB8100F28BC0 /* SuperLoggerDemo.app */; 120 | productType = "com.apple.product-type.application"; 121 | }; 122 | /* End PBXNativeTarget section */ 123 | 124 | /* Begin PBXProject section */ 125 | CBF025FA1A49AB8100F28BC0 /* Project object */ = { 126 | isa = PBXProject; 127 | attributes = { 128 | LastUpgradeCheck = 0810; 129 | ORGANIZATIONNAME = GYX; 130 | TargetAttributes = { 131 | CBF026011A49AB8100F28BC0 = { 132 | CreatedOnToolsVersion = 6.1.1; 133 | DevelopmentTeam = CV2JKHPWU5; 134 | }; 135 | }; 136 | }; 137 | buildConfigurationList = CBF025FD1A49AB8100F28BC0 /* Build configuration list for PBXProject "SuperLoggerDemo" */; 138 | compatibilityVersion = "Xcode 3.2"; 139 | developmentRegion = English; 140 | hasScannedForEncodings = 0; 141 | knownRegions = ( 142 | en, 143 | Base, 144 | de, 145 | "pl-PL", 146 | "zh-CN", 147 | ); 148 | mainGroup = CBF025F91A49AB8100F28BC0; 149 | productRefGroup = CBF026031A49AB8100F28BC0 /* Products */; 150 | projectDirPath = ""; 151 | projectRoot = ""; 152 | targets = ( 153 | CBF026011A49AB8100F28BC0 /* SuperLoggerDemo */, 154 | ); 155 | }; 156 | /* End PBXProject section */ 157 | 158 | /* Begin PBXResourcesBuildPhase section */ 159 | CBF026001A49AB8100F28BC0 /* Resources */ = { 160 | isa = PBXResourcesBuildPhase; 161 | buildActionMask = 2147483647; 162 | files = ( 163 | CBF026111A49AB8100F28BC0 /* Main.storyboard in Resources */, 164 | CBF026161A49AB8100F28BC0 /* LaunchScreen.xib in Resources */, 165 | CBF026131A49AB8100F28BC0 /* Images.xcassets in Resources */, 166 | ); 167 | runOnlyForDeploymentPostprocessing = 0; 168 | }; 169 | /* End PBXResourcesBuildPhase section */ 170 | 171 | /* Begin PBXSourcesBuildPhase section */ 172 | CBF025FE1A49AB8100F28BC0 /* Sources */ = { 173 | isa = PBXSourcesBuildPhase; 174 | buildActionMask = 2147483647; 175 | files = ( 176 | CBF0260E1A49AB8100F28BC0 /* ViewController.m in Sources */, 177 | CBF0260B1A49AB8100F28BC0 /* AppDelegate.m in Sources */, 178 | CBF026081A49AB8100F28BC0 /* main.m in Sources */, 179 | ); 180 | runOnlyForDeploymentPostprocessing = 0; 181 | }; 182 | /* End PBXSourcesBuildPhase section */ 183 | 184 | /* Begin PBXVariantGroup section */ 185 | CBF0260F1A49AB8100F28BC0 /* Main.storyboard */ = { 186 | isa = PBXVariantGroup; 187 | children = ( 188 | CBF026101A49AB8100F28BC0 /* Base */, 189 | ); 190 | name = Main.storyboard; 191 | sourceTree = ""; 192 | }; 193 | CBF026141A49AB8100F28BC0 /* LaunchScreen.xib */ = { 194 | isa = PBXVariantGroup; 195 | children = ( 196 | CBF026151A49AB8100F28BC0 /* Base */, 197 | ); 198 | name = LaunchScreen.xib; 199 | sourceTree = ""; 200 | }; 201 | /* End PBXVariantGroup section */ 202 | 203 | /* Begin XCBuildConfiguration section */ 204 | CBF026231A49AB8100F28BC0 /* Debug */ = { 205 | isa = XCBuildConfiguration; 206 | buildSettings = { 207 | ALWAYS_SEARCH_USER_PATHS = NO; 208 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 209 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 210 | CLANG_CXX_LIBRARY = "libc++"; 211 | CLANG_ENABLE_MODULES = YES; 212 | CLANG_ENABLE_OBJC_ARC = YES; 213 | CLANG_WARN_BOOL_CONVERSION = YES; 214 | CLANG_WARN_CONSTANT_CONVERSION = YES; 215 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 216 | CLANG_WARN_EMPTY_BODY = YES; 217 | CLANG_WARN_ENUM_CONVERSION = YES; 218 | CLANG_WARN_INFINITE_RECURSION = YES; 219 | CLANG_WARN_INT_CONVERSION = YES; 220 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 221 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 222 | CLANG_WARN_UNREACHABLE_CODE = YES; 223 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 224 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 225 | COPY_PHASE_STRIP = NO; 226 | ENABLE_STRICT_OBJC_MSGSEND = YES; 227 | ENABLE_TESTABILITY = YES; 228 | GCC_C_LANGUAGE_STANDARD = gnu99; 229 | GCC_DYNAMIC_NO_PIC = NO; 230 | GCC_NO_COMMON_BLOCKS = YES; 231 | GCC_OPTIMIZATION_LEVEL = 0; 232 | GCC_PREPROCESSOR_DEFINITIONS = ( 233 | "DEBUG=1", 234 | "$(inherited)", 235 | ); 236 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 237 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 238 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 239 | GCC_WARN_UNDECLARED_SELECTOR = YES; 240 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 241 | GCC_WARN_UNUSED_FUNCTION = YES; 242 | GCC_WARN_UNUSED_VARIABLE = YES; 243 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 244 | MTL_ENABLE_DEBUG_INFO = YES; 245 | ONLY_ACTIVE_ARCH = YES; 246 | SDKROOT = iphoneos; 247 | }; 248 | name = Debug; 249 | }; 250 | CBF026241A49AB8100F28BC0 /* Release */ = { 251 | isa = XCBuildConfiguration; 252 | buildSettings = { 253 | ALWAYS_SEARCH_USER_PATHS = NO; 254 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 255 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 256 | CLANG_CXX_LIBRARY = "libc++"; 257 | CLANG_ENABLE_MODULES = YES; 258 | CLANG_ENABLE_OBJC_ARC = YES; 259 | CLANG_WARN_BOOL_CONVERSION = YES; 260 | CLANG_WARN_CONSTANT_CONVERSION = YES; 261 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 262 | CLANG_WARN_EMPTY_BODY = YES; 263 | CLANG_WARN_ENUM_CONVERSION = YES; 264 | CLANG_WARN_INFINITE_RECURSION = YES; 265 | CLANG_WARN_INT_CONVERSION = YES; 266 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 267 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 268 | CLANG_WARN_UNREACHABLE_CODE = YES; 269 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 270 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 271 | COPY_PHASE_STRIP = YES; 272 | ENABLE_NS_ASSERTIONS = NO; 273 | ENABLE_STRICT_OBJC_MSGSEND = YES; 274 | GCC_C_LANGUAGE_STANDARD = gnu99; 275 | GCC_NO_COMMON_BLOCKS = YES; 276 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 277 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 278 | GCC_WARN_UNDECLARED_SELECTOR = YES; 279 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 280 | GCC_WARN_UNUSED_FUNCTION = YES; 281 | GCC_WARN_UNUSED_VARIABLE = YES; 282 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 283 | MTL_ENABLE_DEBUG_INFO = NO; 284 | SDKROOT = iphoneos; 285 | VALIDATE_PRODUCT = YES; 286 | }; 287 | name = Release; 288 | }; 289 | CBF026261A49AB8100F28BC0 /* Debug */ = { 290 | isa = XCBuildConfiguration; 291 | buildSettings = { 292 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 293 | DEVELOPMENT_TEAM = CV2JKHPWU5; 294 | INFOPLIST_FILE = SuperLoggerDemo/Info.plist; 295 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 296 | PRODUCT_BUNDLE_IDENTIFIER = "yourtion.$(PRODUCT_NAME:rfc1034identifier)"; 297 | PRODUCT_NAME = "$(TARGET_NAME)"; 298 | TARGETED_DEVICE_FAMILY = "1,2"; 299 | }; 300 | name = Debug; 301 | }; 302 | CBF026271A49AB8100F28BC0 /* Release */ = { 303 | isa = XCBuildConfiguration; 304 | buildSettings = { 305 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 306 | DEVELOPMENT_TEAM = CV2JKHPWU5; 307 | INFOPLIST_FILE = SuperLoggerDemo/Info.plist; 308 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 309 | PRODUCT_BUNDLE_IDENTIFIER = "yourtion.$(PRODUCT_NAME:rfc1034identifier)"; 310 | PRODUCT_NAME = "$(TARGET_NAME)"; 311 | TARGETED_DEVICE_FAMILY = "1,2"; 312 | }; 313 | name = Release; 314 | }; 315 | /* End XCBuildConfiguration section */ 316 | 317 | /* Begin XCConfigurationList section */ 318 | CBF025FD1A49AB8100F28BC0 /* Build configuration list for PBXProject "SuperLoggerDemo" */ = { 319 | isa = XCConfigurationList; 320 | buildConfigurations = ( 321 | CBF026231A49AB8100F28BC0 /* Debug */, 322 | CBF026241A49AB8100F28BC0 /* Release */, 323 | ); 324 | defaultConfigurationIsVisible = 0; 325 | defaultConfigurationName = Release; 326 | }; 327 | CBF026251A49AB8100F28BC0 /* Build configuration list for PBXNativeTarget "SuperLoggerDemo" */ = { 328 | isa = XCConfigurationList; 329 | buildConfigurations = ( 330 | CBF026261A49AB8100F28BC0 /* Debug */, 331 | CBF026271A49AB8100F28BC0 /* Release */, 332 | ); 333 | defaultConfigurationIsVisible = 0; 334 | defaultConfigurationName = Release; 335 | }; 336 | /* End XCConfigurationList section */ 337 | }; 338 | rootObject = CBF025FA1A49AB8100F28BC0 /* Project object */; 339 | } 340 | -------------------------------------------------------------------------------- /SuperLoggerDemo/SuperLoggerDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SuperLoggerDemo/SuperLoggerDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SuperLoggerDemo 4 | // 5 | // Created by YourtionGuo on 12/23/14. 6 | // Copyright (c) 2014 GYX. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /SuperLoggerDemo/SuperLoggerDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SuperLoggerDemo 4 | // 5 | // Created by YourtionGuo on 12/23/14. 6 | // Copyright (c) 2014 GYX. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | // Override point for customization after application launch. 21 | 22 | SuperLogger *logger = [SuperLogger sharedInstance]; 23 | // Start NSLogToDocument 24 | [logger redirectNSLogToDocumentFolder]; 25 | // Set Email info 26 | logger.mailTitle = @"SuperLoggerDemo Logfile"; 27 | logger.mailContect = @"This is the SuperLoggerDemo Logfile"; 28 | logger.mailRecipients = @[@"yourtion@gmail.com"]; 29 | 30 | return YES; 31 | } 32 | 33 | - (void)applicationWillResignActive:(UIApplication *)application { 34 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 35 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 36 | } 37 | 38 | - (void)applicationDidEnterBackground:(UIApplication *)application { 39 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 40 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 41 | } 42 | 43 | - (void)applicationWillEnterForeground:(UIApplication *)application { 44 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 45 | } 46 | 47 | - (void)applicationDidBecomeActive:(UIApplication *)application { 48 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 49 | } 50 | 51 | - (void)applicationWillTerminate:(UIApplication *)application { 52 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /SuperLoggerDemo/SuperLoggerDemo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /SuperLoggerDemo/SuperLoggerDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 29 | 41 | 53 | 62 | 71 | 80 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /SuperLoggerDemo/SuperLoggerDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /SuperLoggerDemo/SuperLoggerDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | UIInterfaceOrientationPortraitUpsideDown 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /SuperLoggerDemo/SuperLoggerDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // SuperLoggerDemo 4 | // 5 | // Created by YourtionGuo on 12/23/14. 6 | // Copyright (c) 2014 GYX. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /SuperLoggerDemo/SuperLoggerDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // SuperLoggerDemo 4 | // 5 | // Created by YourtionGuo on 12/23/14. 6 | // Copyright (c) 2014 GYX. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view, typically from a nib. 21 | } 22 | 23 | - (void)didReceiveMemoryWarning { 24 | [super didReceiveMemoryWarning]; 25 | // Dispose of any resources that can be recreated. 26 | } 27 | 28 | - (IBAction)addLog:(id)sender { 29 | NSLog(@"This is a log."); 30 | } 31 | 32 | - (IBAction)addCrash:(id)sender { 33 | [self delete:nil]; 34 | } 35 | 36 | - (IBAction)l2logs:(id)sender { 37 | [[SuperLogger sharedInstance]cleanLogsByKeeping:2 deleteStarts:NO]; 38 | } 39 | - (IBAction)l4logs:(id)sender { 40 | [[SuperLogger sharedInstance]cleanLogsByKeeping:2 deleteStarts:YES]; 41 | } 42 | - (IBAction)delCrash:(id)sender { 43 | [[SuperLogger sharedInstance]deleteCrash]; 44 | } 45 | - (IBAction)del5m:(id)sender { 46 | NSDate *five = [[NSDate date]dateByAddingTimeInterval:-60*5]; 47 | [[SuperLogger sharedInstance]cleanLogsBefore:five deleteStarts:YES]; 48 | } 49 | 50 | - (IBAction)showLogList:(id)sender { 51 | [self presentViewController:[[SuperLogger sharedInstance] getListView] animated:YES completion:nil]; 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /SuperLoggerDemo/SuperLoggerDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SuperLoggerDemo 4 | // 5 | // Created by YourtionGuo on 12/23/14. 6 | // Copyright (c) 2014 GYX. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SuperLoggerTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /SuperLoggerTests/SuperLoggerFunctionsTest.m: -------------------------------------------------------------------------------- 1 | // 2 | // SuperLoggerFunctionsTest.m 3 | // SuperLogger 4 | // 5 | // Created by YourtionGuo on 2/19/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "SuperLoggerFunctions.h" 11 | 12 | const NSString *kLogFileFormat = @"yyyy-MM-dd_HH:mm:ss"; 13 | 14 | @interface SuperLoggerFunctionsTest : XCTestCase 15 | @end 16 | 17 | @implementation SuperLoggerFunctionsTest 18 | 19 | - (void)setUp { 20 | [super setUp]; 21 | // Put setup code here. This method is called before the invocation of each test method in the class. 22 | } 23 | 24 | - (void)tearDown { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testGetDateTimeStringWithFormat { 30 | NSString *res = [SuperLoggerFunctions getDateTimeStringWithFormat:[kLogFileFormat copy]]; 31 | XCTAssertNotNil(res); 32 | XCTAssertEqual(res.length, kLogFileFormat.length); 33 | } 34 | 35 | - (void)testFileNotExistAtPath { 36 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 37 | NSString *logDirectory = [paths[0] stringByAppendingPathComponent:@"log"]; 38 | NSString *logFilePath = [logDirectory stringByAppendingPathComponent:@"hello"]; 39 | BOOL exist = [SuperLoggerFunctions isFileExistAtPath:logFilePath]; 40 | XCTAssertEqual(exist, NO); 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /SuperLoggerTests/SuperLoggerTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SuperLoggerTests.m 3 | // SuperLoggerTests 4 | // 5 | // Created by YourtionGuo on 2/19/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "SuperLogger.h" 11 | #import "SuperLoggerFunctions.h" 12 | #import "SuperLoggerPreviewView.h" 13 | 14 | const NSString *kTestInfo = @"Hello"; 15 | const NSString *kCrashLogFileName = @"CrashLog.log"; 16 | 17 | @interface SuperLoggerTests : XCTestCase 18 | @property (nonatomic, strong) NSString *logDirectory; 19 | @end 20 | 21 | @implementation SuperLoggerTests 22 | 23 | - (void)setUp { 24 | [super setUp]; 25 | // Put setup code here. This method is called before the invocation of each test method in the class. 26 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 27 | NSString *logDirectory = [paths[0] stringByAppendingPathComponent:@"log"]; 28 | NSFileManager *fileManager = [NSFileManager defaultManager]; 29 | if (![SuperLoggerFunctions isFileExistAtPath:logDirectory]) { 30 | [fileManager createDirectoryAtPath:logDirectory withIntermediateDirectories:YES attributes:nil error:nil]; 31 | } 32 | NSArray *files = [SuperLoggerFunctions getFilenamelistOfType:@"log" fromDirPath:logDirectory]; 33 | for (NSString *file in files) { 34 | NSString *logFilePath = [logDirectory stringByAppendingPathComponent:file]; 35 | [fileManager removeItemAtPath:logFilePath error:NULL]; 36 | } 37 | self.logDirectory =logDirectory; 38 | NSString *dateStr = [SuperLoggerFunctions getDateTimeStringWithFormat:@"yyyy-MM-dd_HH:mm:ss"]; 39 | NSString *logFilename = [NSString stringWithFormat:@"%@.log",dateStr]; 40 | NSString *logFilePath = [self.logDirectory stringByAppendingPathComponent:logFilename]; 41 | [kTestInfo writeToFile:logFilePath atomically:YES encoding:NSUTF8StringEncoding error:nil]; 42 | } 43 | 44 | - (void)tearDown { 45 | // Put teardown code here. This method is called after the invocation of each test method in the class. 46 | [super tearDown]; 47 | } 48 | 49 | - (void)testSharedInstance { 50 | SuperLogger *logger = [SuperLogger sharedInstance]; 51 | [logger redirectNSLogToDocumentFolder]; 52 | XCTAssertNotNil(logger); 53 | } 54 | 55 | - (void)testGetLogList { 56 | SuperLogger *logger = [SuperLogger sharedInstance]; 57 | NSArray *res1 = [logger getLogList]; 58 | XCTAssertEqual(res1.count, 1); 59 | } 60 | 61 | - (void)testIsStarFile { 62 | SuperLogger *logger = [SuperLogger sharedInstance]; 63 | NSArray *res1 = [logger getLogList]; 64 | XCTAssertEqual(res1.count, 1); 65 | BOOL notStar = [logger isStaredWithFilename:res1.lastObject]; 66 | XCTAssertEqual(notStar, NO); 67 | [logger starWithFilename:res1[0]]; 68 | BOOL stared = [logger isStaredWithFilename:res1.lastObject]; 69 | XCTAssertEqual(stared, YES); 70 | } 71 | 72 | - (void)testPreview { 73 | SuperLogger *logger = [SuperLogger sharedInstance]; 74 | NSArray *res1 = [logger getLogList]; 75 | XCTAssertEqual(res1.count, 1); 76 | SuperLoggerPreviewView *view = [[SuperLoggerPreviewView alloc]init]; 77 | view.logFilename = res1[0]; 78 | view.logData = [logger getDataWithFilename:res1.lastObject]; 79 | [view viewDidLoad]; 80 | XCTAssertEqual(view.navigationItem.title, res1.lastObject); 81 | UITextView *textView; 82 | for (UIView *v in view.view.subviews) { 83 | if (v.tag == 999) { 84 | textView = (UITextView *)v; 85 | } 86 | } 87 | XCTAssertEqualObjects(textView.text, kTestInfo); 88 | } 89 | 90 | - (void)testGetDataWithFilename { 91 | SuperLogger *logger = [SuperLogger sharedInstance]; 92 | NSArray *res1 = [logger getLogList]; 93 | XCTAssertGreaterThanOrEqual(res1.count, 1); 94 | NSData *data = [logger getDataWithFilename:res1.lastObject]; 95 | NSString *str = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; 96 | XCTAssertEqualObjects(str, kTestInfo); 97 | } 98 | 99 | - (void)testDeleteCrash { 100 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 101 | NSString *logDirectory = [paths[0] stringByAppendingPathComponent:@"log"]; 102 | NSString *CrashLogFilePath = [logDirectory stringByAppendingPathComponent:[[kCrashLogFileName copy] copy]]; 103 | [kTestInfo writeToFile:CrashLogFilePath atomically:YES encoding:NSUTF8StringEncoding error:nil]; 104 | SuperLogger *logger = [SuperLogger sharedInstance]; 105 | NSData *data = [logger getDataWithFilename:[kCrashLogFileName copy]]; 106 | NSString *str = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; 107 | XCTAssertEqualObjects(str, kTestInfo); 108 | [logger deleteCrash]; 109 | XCTAssertNil([logger getDataWithFilename:[kCrashLogFileName copy]]); 110 | } 111 | 112 | @end 113 | --------------------------------------------------------------------------------