Skip to content

Commit

Permalink
Modify folder path.
Browse files Browse the repository at this point in the history
  • Loading branch information
HDB-Li committed Sep 19, 2018
1 parent 70f331c commit 3017cec
Show file tree
Hide file tree
Showing 263 changed files with 394 additions and 486 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <execinfo.h>
#import "LLStorageManager.h"
#import "LLCrashModel.h"
#import "LLAppHelper.h"
#import "LLRoute.h"
#import "LLConfig.h"
#import "LLTool.h"
#import "NSObject+LL_Utils.h"
Expand Down Expand Up @@ -153,7 +153,7 @@ - (void)unregisterCatch {

- (void)saveException:(NSException *)exception {
NSString *date = [LLTool stringFromDate:[NSDate date]];
NSArray *appInfos = [[LLAppHelper sharedHelper] appInfos];
NSArray *appInfos = [LLRoute appInfos];

if (self.crashModel) {
LLCrashModel *model = [[LLCrashModel alloc] initWithName:exception.name reason:exception.reason userInfo:exception.userInfo stackSymbols:exception.callStackSymbols date:date userIdentity:[LLConfig sharedConfig].userIdentity appInfos:appInfos launchDate:[NSObject launchDate]];
Expand Down Expand Up @@ -326,16 +326,16 @@ void SignalHandler(int sig)

NSArray *callStackSymbols = [NSThread callStackSymbols];
NSString *date = [LLTool stringFromDate:[NSDate date]];
NSDictionary *appInfos = [[LLAppHelper sharedHelper] dynamicAppInfos];
NSDictionary *appInfos = [LLRoute dynamicAppInfos];
LLCrashSignalModel *signalModel = [[LLCrashSignalModel alloc] initWithName:name stackSymbols:callStackSymbols date:date userIdentity:[LLConfig sharedConfig].userIdentity appInfos:appInfos];
if ([LLCrashHelper sharedHelper].crashModel) {
[[LLCrashHelper sharedHelper].crashModel updateAppInfos:[[LLAppHelper sharedHelper] appInfos]];
[[LLCrashHelper sharedHelper].crashModel updateAppInfos:[LLRoute appInfos]];
[[LLCrashHelper sharedHelper].crashModel appendSignalModel:signalModel];
[[LLStorageManager sharedManager] updateModel:[LLCrashHelper sharedHelper].crashModel complete:^(BOOL result) {
NSLog(@"Save signal model success");
} synchronous:YES];
} else {
LLCrashModel *model = [[LLCrashModel alloc] initWithName:signalModel.name reason:@"Catch Signal" userInfo:nil stackSymbols:callStackSymbols date:date userIdentity:[LLConfig sharedConfig].userIdentity appInfos:[[LLAppHelper sharedHelper] appInfos] launchDate:[NSObject launchDate]];
LLCrashModel *model = [[LLCrashModel alloc] initWithName:signalModel.name reason:@"Catch Signal" userInfo:nil stackSymbols:callStackSymbols date:date userIdentity:[LLConfig sharedConfig].userIdentity appInfos:[LLRoute appInfos] launchDate:[NSObject launchDate]];
[model appendSignalModel:signalModel];
[LLCrashHelper sharedHelper].crashModel = model;
[[LLStorageManager sharedManager] saveModel:model complete:^(BOOL result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@
#import "LLSubTitleTableViewCell.h"
#import "LLMacros.h"
#import "LLStorageManager.h"
#import "LLNetworkVC.h"
#import "LLLogVC.h"
#import "LLConfig.h"
#import "LLTool.h"
#import "LLCrashSignalContentVC.h"
#import "LLRoute.h"

static NSString *const kCrashContentCellID = @"CrashContentCellID";

Expand Down Expand Up @@ -73,12 +72,10 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *title = self.titleArray[indexPath.row];
if ([title isEqualToString:@"Logs"]) {
LLLogVC *vc = [[LLLogVC alloc] initWithStyle:UITableViewStyleGrouped];
vc.launchDate = self.model.launchDate;
UIViewController *vc = [LLRoute viewControllerWithName:@"LLLogVC" params:@{@"launchDate" : self.model.launchDate}];
[self.navigationController pushViewController:vc animated:YES];
} else if ([title isEqualToString:@"Network Requests"]) {
LLNetworkVC *vc = [[LLNetworkVC alloc] initWithStyle:UITableViewStyleGrouped];
vc.launchDate = self.model.launchDate;
UIViewController *vc = [LLRoute viewControllerWithName:@"LLNetworkVC" params:@{@"launchDate" : self.model.launchDate}];
[self.navigationController pushViewController:vc animated:YES];
} else if ([title hasPrefix:@"Signal"]) {
NSInteger index = 0;
Expand Down Expand Up @@ -115,18 +112,29 @@ - (void)initial {
}

- (void)loadData {
__weak typeof(self) weakSelf = self;
[LLTool loadingMessage:@"Loading"];
[[LLStorageManager sharedManager] getModels:[LLLogModel class] launchDate:_model.launchDate complete:^(NSArray<LLStorageModel *> *result) {
// Get log models.
__block NSArray *logs = result;
[[LLStorageManager sharedManager] getModels:[LLNetworkModel class] launchDate:weakSelf.model.launchDate complete:^(NSArray<LLStorageModel *> *result) {
[LLTool hideLoadingMessage];
// Get nework requests.
NSArray *networkRequests = result;
[weakSelf updateDataWithLogs:logs networkRequests:networkRequests];

Class logModelClass = NSClassFromString(kLLLogModelName);
Class networkModelClass = NSClassFromString(kLLNetworkModelName);
if (logModelClass != nil && networkModelClass != nil) {
__weak typeof(self) weakSelf = self;
[LLTool loadingMessage:@"Loading"];
[[LLStorageManager sharedManager] getModels:[LLLogModel class] launchDate:_model.launchDate complete:^(NSArray<LLStorageModel *> *result) {
// Get log models.
__block NSArray *logs = result;
[[LLStorageManager sharedManager] getModels:[LLNetworkModel class] launchDate:weakSelf.model.launchDate complete:^(NSArray<LLStorageModel *> *result) {
[LLTool hideLoadingMessage];
// Get nework requests.
NSArray *networkRequests = result;
[weakSelf updateDataWithLogs:logs networkRequests:networkRequests];
}];
}];
}];
} else if (logModelClass != nil) {

} else if (networkModelClass != nil) {

} else {

}
}

- (void)updateDataWithLogs:(NSArray *)logs networkRequests:(NSArray *)networkRequests {
Expand Down
File renamed without changes.
83 changes: 83 additions & 0 deletions LLDebugTool/Components/General/Function/Route/LLRoute.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
//
// LLRoute.h
//
// Copyright (c) 2018 LLDebugTool Software Foundation (https://github.com/HDB-Li/LLDebugTool)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#import <Foundation/Foundation.h>
#import "LLConfig.h"

// Event
FOUNDATION_EXPORT NSString * _Nonnull const kLLDebugToolEvent;
FOUNDATION_EXPORT NSString * _Nonnull const kLLFailedLoadingResourceEvent;

// Define
FOUNDATION_EXPORT NSString * _Nonnull const kLLUseBetaAlertPrompt;
FOUNDATION_EXPORT NSString * _Nonnull const kLLOpenIssueInGithubPrompt;

static NSString *const kLLNetworkVCName = @"LLNetworkVC";
static NSString *const kLLLogVCName = @"LLLogVC";
static NSString *const kLLNetworkModelName = @"LLNetworkModel";
static NSString *const kLLLogModelName = @"LLLogModel";

@interface LLRoute : NSObject

#pragma mark - DebugTool Route
/**
If LLDebugTool exists, set new availables to LLDebugTool, otherwise nothing will be done.
*/
+ (void)setNewAvailables:(LLConfigAvailableFeature)availables;

/**
If LLDebugTool exists, LLDebugTool's window called showWindow method, otherwise nothing will be done.
*/
+ (void)showWindow;

/**
If LLDebugTool exists, LLDebugTool's window called hideWindow method, otherwise nothing will be done.
*/
+ (void)hideWindow;

#pragma mark - Log Route
/**
If LLLogHelper exists, LLLogHelper is called, otherwise NSLog is called.
*/
+ (void)logWithMessage:(NSString *_Nonnull)message event:(NSString *_Nullable)event;

#pragma mark - App Route
/**
If LLAppHelper exists, LLAppHelper is called, otherwise nothing will be done.
*/
+ (void)updateRequestDataTraffic:(unsigned long long)requestDataTraffic responseDataTraffic:(unsigned long long)responseDataTraffic;

/**
If LLAppHelper exists, LLAppHelper is called, otherwise nothing will be done.
*/
+ (NSMutableArray <NSArray <NSDictionary <NSString *,NSString *>*>*>*_Nonnull)appInfos;

/**
If LLAppHelper exists, LLAppHelper is called, otherwise nothing will be done.
*/
+ (NSDictionary <NSString *, NSString *>*_Nonnull)dynamicAppInfos;

#pragma mark - Base
+ (UIViewController *_Nullable)viewControllerWithName:(NSString *_Nonnull)name params:(NSDictionary <NSString *,id>*)params;

@end
146 changes: 146 additions & 0 deletions LLDebugTool/Components/General/Function/Route/LLRoute.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
//
// LLRoute.m
//
// Copyright (c) 2018 LLDebugTool Software Foundation (https://github.com/HDB-Li/LLDebugTool)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#import "LLRoute.h"
#import "LLBaseViewController.h"

#ifndef INSTALLED_LLDEBUGTOOL
#define INSTALLED_LLDEBUGTOOL (__has_include("LLDebugTool.h") || __has_include("<LLDebugTool/LLDebugTool.h>"))
#endif

#ifndef LL_HAS_INCLUDE_LOG_HELPER
#define LL_HAS_INCLUDE_LOG_HELPER (__has_include("LLLogHelper.h") || __has_include("<LLDebugTool/LLLogHelper.h>"))
#endif

#ifndef LL_HAS_INCLUDE_APP_HELPER
#define LL_HAS_INCLUDE_APP_HELPER (__has_include("LLAppHelper.h") || __has_include("<LLDebugTool/LLAppHelper.h>"))
#endif

#if __has_include("LLDebugTool.h")
#import "LLDebugTool.h"
#import "LLNetworkHelper.h"
#import "LLLogHelper.h"
#import "LLCrashHelper.h"
#import "LLAppHelper.h"
#import "LLScreenshotHelper.h"
#import "LLWindow.h"
#elif __has_include("<LLDebugTool/LLDebugTool.h>")
#import "<LLDebugTool/LLDebugTool.h>"
#import "<LLDebugTool/LLNetworkHelper.h>"
#import "<LLDebugTool/LLLogHelper.h>"
#import "<LLDebugTool/LLCrashHelper.h>"
#import "<LLDebugTool/LLAppHelper.h>"
#import "<LLDebugTool/LLScreenshotHelper.h>"
#import "<LLDebugTool/LLWindow.h>"
#endif

#if __has_include("LLLogHelper.h")
#import "LLLogHelper.h"
#elif __has_include("<LLDebugTool/LLLogHelper.h>")
#import "<LLDebugTool/LLLogHelper.h>"
#endif

#if __has_include("LLAppHelper.h")
#import "LLAppHelper.h"
#elif __has_include("<LLDebugTool/LLAppHelper.h>")
#import "<LLDebugTool/LLAppHelper.h>"
#endif

// Event
NSString * const kLLDebugToolEvent = @"LLDebugTool";
NSString * const kLLFailedLoadingResourceEvent = @"Resource Failed";

// Define
NSString * const kLLUseBetaAlertPrompt = @"You are using a Beta version, please use release version.";
NSString * const kLLOpenIssueInGithubPrompt = @" Open an issue in \"https://github.com/HDB-Li/LLDebugTool\" if you need to get more help.";

@implementation LLRoute

+ (void)logWithMessage:(NSString *_Nonnull)message event:(NSString *_Nullable)event {
#if LL_HAS_INCLUDE_LOG_HELPER
LLog_Alert_Event(event, message);
#else
NSLog(@"%@" , message);
#endif
}

+ (void)setNewAvailables:(LLConfigAvailableFeature)availables {
#if INSTALLED_LLDEBUGTOOL
if ([LLDebugTool sharedTool].isWorking) {
[[LLNetworkHelper sharedHelper] setEnable:networkEnable];
[[LLLogHelper sharedHelper] setEnable:logEnable];
[[LLCrashHelper sharedHelper] setEnable:crashEnable];
[[LLAppHelper sharedHelper] setEnable:appInfoEnable];
[[LLScreenshotHelper sharedHelper] setEnable:screenshotEnable];
}
#endif
}

+ (void)showWindow {
#if INSTALLED_LLDEBUGTOOL
[[LLDebugTool sharedTool].window showWindow];
#endif
}

+ (void)hideWindow {
#if INSTALLED_LLDEBUGTOOL
[[LLDebugTool sharedTool].window hideWindow];
#endif
}

+ (void)updateRequestDataTraffic:(unsigned long long)requestDataTraffic responseDataTraffic:(unsigned long long)responseDataTraffic {
#if LL_HAS_INCLUDE_APP_HELPER
[[LLAppHelper sharedHelper] updateRequestDataTraffic:requestDataTraffic responseDataTraffic:responseDataTraffic];
#endif
}

+ (NSMutableArray <NSArray <NSDictionary <NSString *,NSString *>*>*>*_Nonnull)appInfos {
#if LL_HAS_INCLUDE_APP_HELPER
return [[LLAppHelper sharedHelper] appInfos];
#endif
return nil;
}

+ (NSDictionary <NSString *, NSString *>*_Nonnull)dynamicAppInfos {
#if LL_HAS_INCLUDE_APP_HELPER
return [[LLAppHelper sharedHelper] dynamicAppInfos];
#endif
return nil;
}

+ (UIViewController *_Nullable)viewControllerWithName:(NSString *_Nonnull)name params:(NSDictionary <NSString *,id>*)params {
Class cls = NSClassFromString(name);
if (cls) {
if ([cls isKindOfClass:[LLBaseViewController class]]) {
LLBaseViewController *vc = [[cls alloc] initWithStyle:UITableViewStyleGrouped];
for (NSString *key in params) {
id value = params[key];
[vc setValue:value forKey:key];
}
return vc;
}
}
return nil;
}

@end
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
#import "LLTool.h"
#import "LLConfig.h"
#import "LLMacros.h"
#import "LLDebugToolMacros.h"
#import "LLLogHelperEventDefine.h"
#import "LLRoute.h"

static LLTool *_instance = nil;

Expand Down Expand Up @@ -132,7 +131,7 @@ + (BOOL)createDirectoryAtPath:(NSString *)path {
NSError *error;
[[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error];
if (error) {
LLog_Alert_Event(kLLLogHelperDebugToolEvent, [NSString stringWithFormat:@"Create folder fail, path = %@, error = %@",path,error.description]);
[LLRoute logWithMessage:[NSString stringWithFormat:@"Create folder fail, path = %@, error = %@",path,error.description] event:kLLDebugToolEvent];
NSAssert(!error, error.description);
return NO;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@

#import "LLBaseViewController.h"
#import "LLImageNameConfig.h"
#import "LLDebugTool.h"
#import "LLMacros.h"
#import "LLWindow.h"
#import "LLTool.h"
#import "LLConfig.h"
#import "LLRoute.h"

static NSString *const kEmptyCellID = @"emptyCellID";

Expand All @@ -38,6 +38,15 @@ @interface LLBaseViewController ()

@implementation LLBaseViewController

- (instancetype)init
{
self = [super init];
if (self) {
_style = UITableViewStyleGrouped;
}
return self;
}

- (instancetype)initWithStyle:(UITableViewStyle)style {
if (self = [super init]) {
_style = style;
Expand Down Expand Up @@ -77,7 +86,7 @@ - (void)showAlertControllerWithMessage:(NSString *)message handler:(void (^)(NSI

#pragma mark - Rewrite
- (void)leftItemClick {
[[LLDebugTool sharedTool].window showWindow];
[LLRoute showWindow];
[self dismissViewControllerAnimated:YES completion:nil];
}

Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 3017cec

Please sign in to comment.